
obj/user/forktree:     file format elf32-i386


Disassembly of section .text:

00800020 <_start>:
// starts us running when we are initially loaded into a new environment.
.text
.globl _start
_start:
	// See if we were started with arguments on the stack
	cmpl $USTACKTOP, %esp
  800020:	81 fc 00 e0 bf ee    	cmp    $0xeebfe000,%esp
	jne args_exist
  800026:	75 04                	jne    80002c <args_exist>

	// If not, push dummy argc/argv arguments.
	// This happens when we are loaded by the kernel,
	// because the kernel does not know about passing arguments.
	pushl $0
  800028:	6a 00                	push   $0x0
	pushl $0
  80002a:	6a 00                	push   $0x0

0080002c <args_exist>:

args_exist:
	call libmain
  80002c:	e8 cb 00 00 00       	call   8000fc <libmain>
1:	jmp 1b
  800031:	eb fe                	jmp    800031 <args_exist+0x5>
	...

00800034 <forkchild>:

void forktree(const char *cur);
void prints(const char *cur);
void
forkchild(const char *cur, char branch)
{
  800034:	55                   	push   %ebp
  800035:	89 e5                	mov    %esp,%ebp
  800037:	83 ec 38             	sub    $0x38,%esp
  80003a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80003d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800040:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800043:	0f b6 75 0c          	movzbl 0xc(%ebp),%esi
	char nxt[DEPTH+1];

	if (strlen(cur) >= DEPTH)
  800047:	89 1c 24             	mov    %ebx,(%esp)
  80004a:	e8 01 08 00 00       	call   800850 <strlen>
  80004f:	83 f8 02             	cmp    $0x2,%eax
  800052:	7f 41                	jg     800095 <forkchild+0x61>
		return;

	snprintf(nxt, DEPTH+1, "%s%c", cur, branch);
  800054:	89 f0                	mov    %esi,%eax
  800056:	0f be f0             	movsbl %al,%esi
  800059:	89 74 24 10          	mov    %esi,0x10(%esp)
  80005d:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  800061:	c7 44 24 08 40 2d 80 	movl   $0x802d40,0x8(%esp)
  800068:	00 
  800069:	c7 44 24 04 04 00 00 	movl   $0x4,0x4(%esp)
  800070:	00 
  800071:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800074:	89 04 24             	mov    %eax,(%esp)
  800077:	e8 7d 07 00 00       	call   8007f9 <snprintf>
	if (fork() == 0) {
  80007c:	e8 c1 10 00 00       	call   801142 <fork>
  800081:	85 c0                	test   %eax,%eax
  800083:	75 10                	jne    800095 <forkchild+0x61>
		forktree(nxt);
  800085:	8d 45 f4             	lea    -0xc(%ebp),%eax
  800088:	89 04 24             	mov    %eax,(%esp)
  80008b:	e8 0f 00 00 00       	call   80009f <forktree>
		exit();
  800090:	e8 b7 00 00 00       	call   80014c <exit>
	}
}
  800095:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800098:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80009b:	89 ec                	mov    %ebp,%esp
  80009d:	5d                   	pop    %ebp
  80009e:	c3                   	ret    

0080009f <forktree>:

void
forktree(const char *cur)
{
  80009f:	55                   	push   %ebp
  8000a0:	89 e5                	mov    %esp,%ebp
  8000a2:	53                   	push   %ebx
  8000a3:	83 ec 14             	sub    $0x14,%esp
  8000a6:	8b 5d 08             	mov    0x8(%ebp),%ebx
	cprintf("%04x: I am '%s'\n", sys_getenvid(), cur);
  8000a9:	e8 db 0f 00 00       	call   801089 <sys_getenvid>
  8000ae:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8000b2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8000b6:	c7 04 24 45 2d 80 00 	movl   $0x802d45,(%esp)
  8000bd:	e8 07 01 00 00       	call   8001c9 <cprintf>

	forkchild(cur, '0');
  8000c2:	c7 44 24 04 30 00 00 	movl   $0x30,0x4(%esp)
  8000c9:	00 
  8000ca:	89 1c 24             	mov    %ebx,(%esp)
  8000cd:	e8 62 ff ff ff       	call   800034 <forkchild>
	forkchild(cur, '1');
  8000d2:	c7 44 24 04 31 00 00 	movl   $0x31,0x4(%esp)
  8000d9:	00 
  8000da:	89 1c 24             	mov    %ebx,(%esp)
  8000dd:	e8 52 ff ff ff       	call   800034 <forkchild>
}
  8000e2:	83 c4 14             	add    $0x14,%esp
  8000e5:	5b                   	pop    %ebx
  8000e6:	5d                   	pop    %ebp
  8000e7:	c3                   	ret    

008000e8 <umain>:

void
umain(void)
{
  8000e8:	55                   	push   %ebp
  8000e9:	89 e5                	mov    %esp,%ebp
  8000eb:	83 ec 18             	sub    $0x18,%esp
	forktree("");
  8000ee:	c7 04 24 55 2d 80 00 	movl   $0x802d55,(%esp)
  8000f5:	e8 a5 ff ff ff       	call   80009f <forktree>
}
  8000fa:	c9                   	leave  
  8000fb:	c3                   	ret    

008000fc <libmain>:
volatile struct Env *env;
char *binaryname = "(PROGRAM NAME UNKNOWN)";

void
libmain(int argc, char **argv)
{
  8000fc:	55                   	push   %ebp
  8000fd:	89 e5                	mov    %esp,%ebp
  8000ff:	83 ec 18             	sub    $0x18,%esp
  800102:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  800105:	89 75 fc             	mov    %esi,-0x4(%ebp)
  800108:	8b 75 08             	mov    0x8(%ebp),%esi
  80010b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	// set env to point at our env structure in envs[].
	// LAB 3: Your code here.
  envid_t envid   = sys_getenvid();
  80010e:	e8 76 0f 00 00       	call   801089 <sys_getenvid>
	env = &envs [ENVX(envid)];
  800113:	25 ff 03 00 00       	and    $0x3ff,%eax
  800118:	6b c0 7c             	imul   $0x7c,%eax,%eax
  80011b:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  800120:	a3 74 70 80 00       	mov    %eax,0x807074

	// save the name of the program so that panic() can use it
	if (argc > 0)
  800125:	85 f6                	test   %esi,%esi
  800127:	7e 07                	jle    800130 <libmain+0x34>
		binaryname = argv[0];
  800129:	8b 03                	mov    (%ebx),%eax
  80012b:	a3 00 70 80 00       	mov    %eax,0x807000

	// call user main routine
	umain(argc, argv);
  800130:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800134:	89 34 24             	mov    %esi,(%esp)
  800137:	e8 ac ff ff ff       	call   8000e8 <umain>

	// exit gracefully
	exit();
  80013c:	e8 0b 00 00 00       	call   80014c <exit>
}
  800141:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  800144:	8b 75 fc             	mov    -0x4(%ebp),%esi
  800147:	89 ec                	mov    %ebp,%esp
  800149:	5d                   	pop    %ebp
  80014a:	c3                   	ret    
	...

0080014c <exit>:

#include <inc/lib.h>

void
exit(void)
{
  80014c:	55                   	push   %ebp
  80014d:	89 e5                	mov    %esp,%ebp
  80014f:	83 ec 18             	sub    $0x18,%esp
	close_all();
  800152:	e8 02 19 00 00       	call   801a59 <close_all>
	sys_env_destroy(0);
  800157:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80015e:	e8 5a 0f 00 00       	call   8010bd <sys_env_destroy>
}
  800163:	c9                   	leave  
  800164:	c3                   	ret    
  800165:	00 00                	add    %al,(%eax)
	...

00800168 <vcprintf>:
	b->cnt++;
}

int
vcprintf(const char *fmt, va_list ap)
{
  800168:	55                   	push   %ebp
  800169:	89 e5                	mov    %esp,%ebp
  80016b:	81 ec 28 01 00 00    	sub    $0x128,%esp
	struct printbuf b;

	b.idx = 0;
  800171:	c7 85 f0 fe ff ff 00 	movl   $0x0,-0x110(%ebp)
  800178:	00 00 00 
	b.cnt = 0;
  80017b:	c7 85 f4 fe ff ff 00 	movl   $0x0,-0x10c(%ebp)
  800182:	00 00 00 
	vprintfmt((void*)putch, &b, fmt, ap);
  800185:	8b 45 0c             	mov    0xc(%ebp),%eax
  800188:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80018c:	8b 45 08             	mov    0x8(%ebp),%eax
  80018f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800193:	8d 85 f0 fe ff ff    	lea    -0x110(%ebp),%eax
  800199:	89 44 24 04          	mov    %eax,0x4(%esp)
  80019d:	c7 04 24 e3 01 80 00 	movl   $0x8001e3,(%esp)
  8001a4:	e8 d4 01 00 00       	call   80037d <vprintfmt>
	sys_cputs(b.buf, b.idx);
  8001a9:	8b 85 f0 fe ff ff    	mov    -0x110(%ebp),%eax
  8001af:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001b3:	8d 85 f8 fe ff ff    	lea    -0x108(%ebp),%eax
  8001b9:	89 04 24             	mov    %eax,(%esp)
  8001bc:	e8 cf 0a 00 00       	call   800c90 <sys_cputs>

	return b.cnt;
}
  8001c1:	8b 85 f4 fe ff ff    	mov    -0x10c(%ebp),%eax
  8001c7:	c9                   	leave  
  8001c8:	c3                   	ret    

008001c9 <cprintf>:

int
cprintf(const char *fmt, ...)
{
  8001c9:	55                   	push   %ebp
  8001ca:	89 e5                	mov    %esp,%ebp
  8001cc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
cprintf(const char *fmt, ...)
  8001cf:	8d 45 0c             	lea    0xc(%ebp),%eax
{
	va_list ap;
	int cnt;

	va_start(ap, fmt);
	cnt = vcprintf(fmt, ap);
  8001d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8001d6:	8b 45 08             	mov    0x8(%ebp),%eax
  8001d9:	89 04 24             	mov    %eax,(%esp)
  8001dc:	e8 87 ff ff ff       	call   800168 <vcprintf>
	va_end(ap);

	return cnt;
}
  8001e1:	c9                   	leave  
  8001e2:	c3                   	ret    

008001e3 <putch>:
};


static void
putch(int ch, struct printbuf *b)
{
  8001e3:	55                   	push   %ebp
  8001e4:	89 e5                	mov    %esp,%ebp
  8001e6:	53                   	push   %ebx
  8001e7:	83 ec 14             	sub    $0x14,%esp
  8001ea:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	b->buf[b->idx++] = ch;
  8001ed:	8b 03                	mov    (%ebx),%eax
  8001ef:	8b 55 08             	mov    0x8(%ebp),%edx
  8001f2:	88 54 03 08          	mov    %dl,0x8(%ebx,%eax,1)
  8001f6:	83 c0 01             	add    $0x1,%eax
  8001f9:	89 03                	mov    %eax,(%ebx)
	if (b->idx == 256-1) {
  8001fb:	3d ff 00 00 00       	cmp    $0xff,%eax
  800200:	75 19                	jne    80021b <putch+0x38>
		sys_cputs(b->buf, b->idx);
  800202:	c7 44 24 04 ff 00 00 	movl   $0xff,0x4(%esp)
  800209:	00 
  80020a:	8d 43 08             	lea    0x8(%ebx),%eax
  80020d:	89 04 24             	mov    %eax,(%esp)
  800210:	e8 7b 0a 00 00       	call   800c90 <sys_cputs>
		b->idx = 0;
  800215:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
	}
	b->cnt++;
  80021b:	83 43 04 01          	addl   $0x1,0x4(%ebx)
}
  80021f:	83 c4 14             	add    $0x14,%esp
  800222:	5b                   	pop    %ebx
  800223:	5d                   	pop    %ebp
  800224:	c3                   	ret    
	...

00800230 <printnum>:
 * using specified putch function and associated pointer putdat.
 */
static void
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
  800230:	55                   	push   %ebp
  800231:	89 e5                	mov    %esp,%ebp
  800233:	57                   	push   %edi
  800234:	56                   	push   %esi
  800235:	53                   	push   %ebx
  800236:	83 ec 4c             	sub    $0x4c,%esp
  800239:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  80023c:	89 d6                	mov    %edx,%esi
  80023e:	8b 45 08             	mov    0x8(%ebp),%eax
  800241:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800244:	8b 55 0c             	mov    0xc(%ebp),%edx
  800247:	89 55 e0             	mov    %edx,-0x20(%ebp)
  80024a:	8b 45 10             	mov    0x10(%ebp),%eax
  80024d:	8b 5d 14             	mov    0x14(%ebp),%ebx
  800250:	8b 7d 18             	mov    0x18(%ebp),%edi
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
  800253:	89 45 dc             	mov    %eax,-0x24(%ebp)
  800256:	b9 00 00 00 00       	mov    $0x0,%ecx
  80025b:	39 d1                	cmp    %edx,%ecx
  80025d:	72 15                	jb     800274 <printnum+0x44>
  80025f:	77 07                	ja     800268 <printnum+0x38>
  800261:	8b 55 d8             	mov    -0x28(%ebp),%edx
  800264:	39 d0                	cmp    %edx,%eax
  800266:	76 0c                	jbe    800274 <printnum+0x44>
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  800268:	83 eb 01             	sub    $0x1,%ebx
  80026b:	85 db                	test   %ebx,%ebx
  80026d:	8d 76 00             	lea    0x0(%esi),%esi
  800270:	7f 61                	jg     8002d3 <printnum+0xa3>
  800272:	eb 70                	jmp    8002e4 <printnum+0xb4>
printnum(void (*putch)(int, void*), void *putdat,
	 unsigned long long num, unsigned base, int width, int padc)
{
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
  800274:	89 7c 24 10          	mov    %edi,0x10(%esp)
  800278:	83 eb 01             	sub    $0x1,%ebx
  80027b:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  80027f:	89 44 24 08          	mov    %eax,0x8(%esp)
  800283:	8b 4c 24 08          	mov    0x8(%esp),%ecx
  800287:	8b 5c 24 0c          	mov    0xc(%esp),%ebx
  80028b:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  80028e:	89 5d d4             	mov    %ebx,-0x2c(%ebp)
  800291:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800294:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  800298:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  80029f:	00 
  8002a0:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8002a3:	89 04 24             	mov    %eax,(%esp)
  8002a6:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8002a9:	89 54 24 04          	mov    %edx,0x4(%esp)
  8002ad:	e8 0e 28 00 00       	call   802ac0 <__udivdi3>
  8002b2:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  8002b5:	8b 5d d4             	mov    -0x2c(%ebp),%ebx
  8002b8:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8002bc:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  8002c0:	89 04 24             	mov    %eax,(%esp)
  8002c3:	89 54 24 04          	mov    %edx,0x4(%esp)
  8002c7:	89 f2                	mov    %esi,%edx
  8002c9:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8002cc:	e8 5f ff ff ff       	call   800230 <printnum>
  8002d1:	eb 11                	jmp    8002e4 <printnum+0xb4>
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
			putch(padc, putdat);
  8002d3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8002d7:	89 3c 24             	mov    %edi,(%esp)
  8002da:	ff 55 e4             	call   *-0x1c(%ebp)
	// first recursively print all preceding (more significant) digits
	if (num >= base) {
		printnum(putch, putdat, num / base, base, width - 1, padc);
	} else {
		// print any needed pad characters before first digit
		while (--width > 0)
  8002dd:	83 eb 01             	sub    $0x1,%ebx
  8002e0:	85 db                	test   %ebx,%ebx
  8002e2:	7f ef                	jg     8002d3 <printnum+0xa3>
			putch(padc, putdat);
	}

	// then print this (the least significant) digit
	putch("0123456789abcdef"[num % base], putdat);
  8002e4:	89 74 24 04          	mov    %esi,0x4(%esp)
  8002e8:	8b 74 24 04          	mov    0x4(%esp),%esi
  8002ec:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8002ef:	89 44 24 08          	mov    %eax,0x8(%esp)
  8002f3:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  8002fa:	00 
  8002fb:	8b 55 d8             	mov    -0x28(%ebp),%edx
  8002fe:	89 14 24             	mov    %edx,(%esp)
  800301:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800304:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800308:	e8 e3 28 00 00       	call   802bf0 <__umoddi3>
  80030d:	89 74 24 04          	mov    %esi,0x4(%esp)
  800311:	0f be 80 6d 2d 80 00 	movsbl 0x802d6d(%eax),%eax
  800318:	89 04 24             	mov    %eax,(%esp)
  80031b:	ff 55 e4             	call   *-0x1c(%ebp)
}
  80031e:	83 c4 4c             	add    $0x4c,%esp
  800321:	5b                   	pop    %ebx
  800322:	5e                   	pop    %esi
  800323:	5f                   	pop    %edi
  800324:	5d                   	pop    %ebp
  800325:	c3                   	ret    

00800326 <getuint>:

// Get an unsigned int of various possible sizes from a varargs list,
// depending on the lflag parameter.
static unsigned long long
getuint(va_list *ap, int lflag)
{
  800326:	55                   	push   %ebp
  800327:	89 e5                	mov    %esp,%ebp
	if (lflag >= 2)
  800329:	83 fa 01             	cmp    $0x1,%edx
  80032c:	7e 0e                	jle    80033c <getuint+0x16>
		return va_arg(*ap, unsigned long long);
  80032e:	8b 10                	mov    (%eax),%edx
  800330:	8d 4a 08             	lea    0x8(%edx),%ecx
  800333:	89 08                	mov    %ecx,(%eax)
  800335:	8b 02                	mov    (%edx),%eax
  800337:	8b 52 04             	mov    0x4(%edx),%edx
  80033a:	eb 22                	jmp    80035e <getuint+0x38>
	else if (lflag)
  80033c:	85 d2                	test   %edx,%edx
  80033e:	74 10                	je     800350 <getuint+0x2a>
		return va_arg(*ap, unsigned long);
  800340:	8b 10                	mov    (%eax),%edx
  800342:	8d 4a 04             	lea    0x4(%edx),%ecx
  800345:	89 08                	mov    %ecx,(%eax)
  800347:	8b 02                	mov    (%edx),%eax
  800349:	ba 00 00 00 00       	mov    $0x0,%edx
  80034e:	eb 0e                	jmp    80035e <getuint+0x38>
	else
		return va_arg(*ap, unsigned int);
  800350:	8b 10                	mov    (%eax),%edx
  800352:	8d 4a 04             	lea    0x4(%edx),%ecx
  800355:	89 08                	mov    %ecx,(%eax)
  800357:	8b 02                	mov    (%edx),%eax
  800359:	ba 00 00 00 00       	mov    $0x0,%edx
}
  80035e:	5d                   	pop    %ebp
  80035f:	c3                   	ret    

00800360 <sprintputch>:
	int cnt;
};

static void
sprintputch(int ch, struct sprintbuf *b)
{
  800360:	55                   	push   %ebp
  800361:	89 e5                	mov    %esp,%ebp
  800363:	8b 45 0c             	mov    0xc(%ebp),%eax
	b->cnt++;
  800366:	83 40 08 01          	addl   $0x1,0x8(%eax)
	if (b->buf < b->ebuf)
  80036a:	8b 10                	mov    (%eax),%edx
  80036c:	3b 50 04             	cmp    0x4(%eax),%edx
  80036f:	73 0a                	jae    80037b <sprintputch+0x1b>
		*b->buf++ = ch;
  800371:	8b 4d 08             	mov    0x8(%ebp),%ecx
  800374:	88 0a                	mov    %cl,(%edx)
  800376:	83 c2 01             	add    $0x1,%edx
  800379:	89 10                	mov    %edx,(%eax)
}
  80037b:	5d                   	pop    %ebp
  80037c:	c3                   	ret    

0080037d <vprintfmt>:
// Main function to format and print a string.
void printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...);

void
vprintfmt(void (*putch)(int, void*), void *putdat, const char *fmt, va_list ap)
{
  80037d:	55                   	push   %ebp
  80037e:	89 e5                	mov    %esp,%ebp
  800380:	57                   	push   %edi
  800381:	56                   	push   %esi
  800382:	53                   	push   %ebx
  800383:	83 ec 5c             	sub    $0x5c,%esp
  800386:	8b 7d 08             	mov    0x8(%ebp),%edi
  800389:	8b 75 0c             	mov    0xc(%ebp),%esi
  80038c:	8b 5d 10             	mov    0x10(%ebp),%ebx
		case '#':
			altflag = 1;
			goto reswitch;

		process_precision:
			if (width < 0)
  80038f:	c7 45 c8 ff ff ff ff 	movl   $0xffffffff,-0x38(%ebp)
  800396:	eb 11                	jmp    8003a9 <vprintfmt+0x2c>
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
			if (ch == '\0')
  800398:	85 c0                	test   %eax,%eax
  80039a:	0f 84 f9 03 00 00    	je     800799 <vprintfmt+0x41c>
				return;
			putch(ch, putdat);
  8003a0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8003a4:	89 04 24             	mov    %eax,(%esp)
  8003a7:	ff d7                	call   *%edi
	unsigned long long num;
	int base, lflag, width, precision, altflag;
	char padc;

	while (1) {
		while ((ch = *(unsigned char *) fmt++) != '%') {
  8003a9:	0f b6 03             	movzbl (%ebx),%eax
  8003ac:	83 c3 01             	add    $0x1,%ebx
  8003af:	83 f8 25             	cmp    $0x25,%eax
  8003b2:	75 e4                	jne    800398 <vprintfmt+0x1b>
  8003b4:	c6 45 d4 20          	movb   $0x20,-0x2c(%ebp)
  8003b8:	c7 45 d8 00 00 00 00 	movl   $0x0,-0x28(%ebp)
  8003bf:	c7 45 d0 ff ff ff ff 	movl   $0xffffffff,-0x30(%ebp)
  8003c6:	c7 45 e4 ff ff ff ff 	movl   $0xffffffff,-0x1c(%ebp)
  8003cd:	b9 00 00 00 00       	mov    $0x0,%ecx
  8003d2:	eb 06                	jmp    8003da <vprintfmt+0x5d>
  8003d4:	c6 45 d4 2d          	movb   $0x2d,-0x2c(%ebp)
  8003d8:	89 c3                	mov    %eax,%ebx
		width = -1;
		precision = -1;
		lflag = 0;
		altflag = 0;
	reswitch:
		switch (ch = *(unsigned char *) fmt++) {
  8003da:	0f b6 13             	movzbl (%ebx),%edx
  8003dd:	0f b6 c2             	movzbl %dl,%eax
  8003e0:	89 45 e0             	mov    %eax,-0x20(%ebp)
  8003e3:	8d 43 01             	lea    0x1(%ebx),%eax
  8003e6:	83 ea 23             	sub    $0x23,%edx
  8003e9:	80 fa 55             	cmp    $0x55,%dl
  8003ec:	0f 87 8a 03 00 00    	ja     80077c <vprintfmt+0x3ff>
  8003f2:	0f b6 d2             	movzbl %dl,%edx
  8003f5:	ff 24 95 a0 2e 80 00 	jmp    *0x802ea0(,%edx,4)
  8003fc:	c6 45 d4 30          	movb   $0x30,-0x2c(%ebp)
  800400:	eb d6                	jmp    8003d8 <vprintfmt+0x5b>
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
				precision = precision * 10 + ch - '0';
  800402:	8b 55 e0             	mov    -0x20(%ebp),%edx
  800405:	83 ea 30             	sub    $0x30,%edx
  800408:	89 55 d0             	mov    %edx,-0x30(%ebp)
				ch = *fmt;
  80040b:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  80040e:	8d 5a d0             	lea    -0x30(%edx),%ebx
  800411:	83 fb 09             	cmp    $0x9,%ebx
  800414:	77 54                	ja     80046a <vprintfmt+0xed>
  800416:	89 4d e0             	mov    %ecx,-0x20(%ebp)
  800419:	8b 4d d0             	mov    -0x30(%ebp),%ecx
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			for (precision = 0; ; ++fmt) {
  80041c:	83 c0 01             	add    $0x1,%eax
				precision = precision * 10 + ch - '0';
  80041f:	8d 0c 89             	lea    (%ecx,%ecx,4),%ecx
  800422:	8d 4c 4a d0          	lea    -0x30(%edx,%ecx,2),%ecx
				ch = *fmt;
  800426:	0f be 10             	movsbl (%eax),%edx
				if (ch < '0' || ch > '9')
  800429:	8d 5a d0             	lea    -0x30(%edx),%ebx
  80042c:	83 fb 09             	cmp    $0x9,%ebx
  80042f:	76 eb                	jbe    80041c <vprintfmt+0x9f>
  800431:	89 4d d0             	mov    %ecx,-0x30(%ebp)
  800434:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800437:	eb 31                	jmp    80046a <vprintfmt+0xed>
					break;
			}
			goto process_precision;

		case '*':
			precision = va_arg(ap, int);
  800439:	8b 55 14             	mov    0x14(%ebp),%edx
  80043c:	8d 5a 04             	lea    0x4(%edx),%ebx
  80043f:	89 5d 14             	mov    %ebx,0x14(%ebp)
  800442:	8b 12                	mov    (%edx),%edx
  800444:	89 55 d0             	mov    %edx,-0x30(%ebp)
			goto process_precision;
  800447:	eb 21                	jmp    80046a <vprintfmt+0xed>

		case '.':
			if (width < 0)
  800449:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80044d:	ba 00 00 00 00       	mov    $0x0,%edx
  800452:	0f 49 55 e4          	cmovns -0x1c(%ebp),%edx
  800456:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800459:	e9 7a ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
  80045e:	c7 45 d8 01 00 00 00 	movl   $0x1,-0x28(%ebp)
				width = 0;
			goto reswitch;

		case '#':
			altflag = 1;
			goto reswitch;
  800465:	e9 6e ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>

		process_precision:
			if (width < 0)
  80046a:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  80046e:	0f 89 64 ff ff ff    	jns    8003d8 <vprintfmt+0x5b>
  800474:	8b 55 d0             	mov    -0x30(%ebp),%edx
  800477:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  80047a:	8b 55 c8             	mov    -0x38(%ebp),%edx
  80047d:	89 55 d0             	mov    %edx,-0x30(%ebp)
  800480:	e9 53 ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
				width = precision, precision = -1;
			goto reswitch;

		// long flag (doubled for long long)
		case 'l':
			lflag++;
  800485:	83 c1 01             	add    $0x1,%ecx
			goto reswitch;
  800488:	e9 4b ff ff ff       	jmp    8003d8 <vprintfmt+0x5b>
  80048d:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// character
		case 'c':
			putch(va_arg(ap, int), putdat);
  800490:	8b 45 14             	mov    0x14(%ebp),%eax
  800493:	8d 50 04             	lea    0x4(%eax),%edx
  800496:	89 55 14             	mov    %edx,0x14(%ebp)
  800499:	89 74 24 04          	mov    %esi,0x4(%esp)
  80049d:	8b 00                	mov    (%eax),%eax
  80049f:	89 04 24             	mov    %eax,(%esp)
  8004a2:	ff d7                	call   *%edi
  8004a4:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  8004a7:	e9 fd fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  8004ac:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// error message
		case 'e':
			err = va_arg(ap, int);
  8004af:	8b 45 14             	mov    0x14(%ebp),%eax
  8004b2:	8d 50 04             	lea    0x4(%eax),%edx
  8004b5:	89 55 14             	mov    %edx,0x14(%ebp)
  8004b8:	8b 00                	mov    (%eax),%eax
  8004ba:	89 c2                	mov    %eax,%edx
  8004bc:	c1 fa 1f             	sar    $0x1f,%edx
  8004bf:	31 d0                	xor    %edx,%eax
  8004c1:	29 d0                	sub    %edx,%eax
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8004c3:	83 f8 12             	cmp    $0x12,%eax
  8004c6:	7f 0b                	jg     8004d3 <vprintfmt+0x156>
  8004c8:	8b 14 85 00 30 80 00 	mov    0x803000(,%eax,4),%edx
  8004cf:	85 d2                	test   %edx,%edx
  8004d1:	75 20                	jne    8004f3 <vprintfmt+0x176>
				printfmt(putch, putdat, "error %d", err);
  8004d3:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8004d7:	c7 44 24 08 7e 2d 80 	movl   $0x802d7e,0x8(%esp)
  8004de:	00 
  8004df:	89 74 24 04          	mov    %esi,0x4(%esp)
  8004e3:	89 3c 24             	mov    %edi,(%esp)
  8004e6:	e8 36 03 00 00       	call   800821 <printfmt>
  8004eb:	8b 5d cc             	mov    -0x34(%ebp),%ebx
		// error message
		case 'e':
			err = va_arg(ap, int);
			if (err < 0)
				err = -err;
			if (err > MAXERROR || (p = error_string[err]) == NULL)
  8004ee:	e9 b6 fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
				printfmt(putch, putdat, "error %d", err);
			else
				printfmt(putch, putdat, "%s", p);
  8004f3:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8004f7:	c7 44 24 08 12 33 80 	movl   $0x803312,0x8(%esp)
  8004fe:	00 
  8004ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800503:	89 3c 24             	mov    %edi,(%esp)
  800506:	e8 16 03 00 00       	call   800821 <printfmt>
  80050b:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  80050e:	e9 96 fe ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  800513:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800516:	89 c3                	mov    %eax,%ebx
  800518:	8b 4d d0             	mov    -0x30(%ebp),%ecx
  80051b:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80051e:	89 45 c4             	mov    %eax,-0x3c(%ebp)
			break;

		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
  800521:	8b 45 14             	mov    0x14(%ebp),%eax
  800524:	8d 50 04             	lea    0x4(%eax),%edx
  800527:	89 55 14             	mov    %edx,0x14(%ebp)
  80052a:	8b 00                	mov    (%eax),%eax
  80052c:	89 45 e0             	mov    %eax,-0x20(%ebp)
  80052f:	85 c0                	test   %eax,%eax
  800531:	b8 87 2d 80 00       	mov    $0x802d87,%eax
  800536:	0f 45 45 e0          	cmovne -0x20(%ebp),%eax
  80053a:	89 45 e0             	mov    %eax,-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
  80053d:	83 7d c4 00          	cmpl   $0x0,-0x3c(%ebp)
  800541:	7e 06                	jle    800549 <vprintfmt+0x1cc>
  800543:	80 7d d4 2d          	cmpb   $0x2d,-0x2c(%ebp)
  800547:	75 13                	jne    80055c <vprintfmt+0x1df>
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  800549:	8b 55 e0             	mov    -0x20(%ebp),%edx
  80054c:	0f be 02             	movsbl (%edx),%eax
  80054f:	85 c0                	test   %eax,%eax
  800551:	0f 85 9b 00 00 00    	jne    8005f2 <vprintfmt+0x275>
  800557:	e9 88 00 00 00       	jmp    8005e4 <vprintfmt+0x267>
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80055c:	89 4c 24 04          	mov    %ecx,0x4(%esp)
  800560:	8b 4d e0             	mov    -0x20(%ebp),%ecx
  800563:	89 0c 24             	mov    %ecx,(%esp)
  800566:	e8 00 03 00 00       	call   80086b <strnlen>
  80056b:	8b 55 c4             	mov    -0x3c(%ebp),%edx
  80056e:	29 c2                	sub    %eax,%edx
  800570:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  800573:	85 d2                	test   %edx,%edx
  800575:	7e d2                	jle    800549 <vprintfmt+0x1cc>
					putch(padc, putdat);
  800577:	0f be 4d d4          	movsbl -0x2c(%ebp),%ecx
  80057b:	89 4d d4             	mov    %ecx,-0x2c(%ebp)
  80057e:	89 5d c4             	mov    %ebx,-0x3c(%ebp)
  800581:	89 d3                	mov    %edx,%ebx
  800583:	89 74 24 04          	mov    %esi,0x4(%esp)
  800587:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  80058a:	89 04 24             	mov    %eax,(%esp)
  80058d:	ff d7                	call   *%edi
		// string
		case 's':
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
  80058f:	83 eb 01             	sub    $0x1,%ebx
  800592:	85 db                	test   %ebx,%ebx
  800594:	7f ed                	jg     800583 <vprintfmt+0x206>
  800596:	8b 5d c4             	mov    -0x3c(%ebp),%ebx
  800599:	c7 45 e4 00 00 00 00 	movl   $0x0,-0x1c(%ebp)
  8005a0:	eb a7                	jmp    800549 <vprintfmt+0x1cc>
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8005a2:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  8005a6:	74 1a                	je     8005c2 <vprintfmt+0x245>
  8005a8:	8d 50 e0             	lea    -0x20(%eax),%edx
  8005ab:	83 fa 5e             	cmp    $0x5e,%edx
  8005ae:	76 12                	jbe    8005c2 <vprintfmt+0x245>
					putch('?', putdat);
  8005b0:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8005b4:	c7 04 24 3f 00 00 00 	movl   $0x3f,(%esp)
  8005bb:	ff 55 e0             	call   *-0x20(%ebp)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
  8005be:	66 90                	xchg   %ax,%ax
  8005c0:	eb 0a                	jmp    8005cc <vprintfmt+0x24f>
					putch('?', putdat);
				else
					putch(ch, putdat);
  8005c2:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8005c6:	89 04 24             	mov    %eax,(%esp)
  8005c9:	ff 55 e0             	call   *-0x20(%ebp)
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8005cc:	83 6d e4 01          	subl   $0x1,-0x1c(%ebp)
  8005d0:	0f be 03             	movsbl (%ebx),%eax
  8005d3:	85 c0                	test   %eax,%eax
  8005d5:	74 05                	je     8005dc <vprintfmt+0x25f>
  8005d7:	83 c3 01             	add    $0x1,%ebx
  8005da:	eb 29                	jmp    800605 <vprintfmt+0x288>
  8005dc:	89 fe                	mov    %edi,%esi
  8005de:	8b 7d e0             	mov    -0x20(%ebp),%edi
  8005e1:	8b 5d d0             	mov    -0x30(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  8005e4:	83 7d e4 00          	cmpl   $0x0,-0x1c(%ebp)
  8005e8:	7f 2e                	jg     800618 <vprintfmt+0x29b>
  8005ea:	8b 5d cc             	mov    -0x34(%ebp),%ebx
  8005ed:	e9 b7 fd ff ff       	jmp    8003a9 <vprintfmt+0x2c>
			if ((p = va_arg(ap, char *)) == NULL)
				p = "(null)";
			if (width > 0 && padc != '-')
				for (width -= strnlen(p, precision); width > 0; width--)
					putch(padc, putdat);
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
  8005f2:	8b 55 e0             	mov    -0x20(%ebp),%edx
  8005f5:	83 c2 01             	add    $0x1,%edx
  8005f8:	89 7d e0             	mov    %edi,-0x20(%ebp)
  8005fb:	89 f7                	mov    %esi,%edi
  8005fd:	8b 75 d0             	mov    -0x30(%ebp),%esi
  800600:	89 5d d0             	mov    %ebx,-0x30(%ebp)
  800603:	89 d3                	mov    %edx,%ebx
  800605:	85 f6                	test   %esi,%esi
  800607:	78 99                	js     8005a2 <vprintfmt+0x225>
  800609:	83 ee 01             	sub    $0x1,%esi
  80060c:	79 94                	jns    8005a2 <vprintfmt+0x225>
  80060e:	89 fe                	mov    %edi,%esi
  800610:	8b 7d e0             	mov    -0x20(%ebp),%edi
  800613:	8b 5d d0             	mov    -0x30(%ebp),%ebx
  800616:	eb cc                	jmp    8005e4 <vprintfmt+0x267>
  800618:	89 5d d8             	mov    %ebx,-0x28(%ebp)
  80061b:	8b 5d e4             	mov    -0x1c(%ebp),%ebx
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
				putch(' ', putdat);
  80061e:	89 74 24 04          	mov    %esi,0x4(%esp)
  800622:	c7 04 24 20 00 00 00 	movl   $0x20,(%esp)
  800629:	ff d7                	call   *%edi
			for (; (ch = *p++) != '\0' && (precision < 0 || --precision >= 0); width--)
				if (altflag && (ch < ' ' || ch > '~'))
					putch('?', putdat);
				else
					putch(ch, putdat);
			for (; width > 0; width--)
  80062b:	83 eb 01             	sub    $0x1,%ebx
  80062e:	85 db                	test   %ebx,%ebx
  800630:	7f ec                	jg     80061e <vprintfmt+0x2a1>
  800632:	8b 5d d8             	mov    -0x28(%ebp),%ebx
  800635:	e9 6f fd ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  80063a:	89 45 cc             	mov    %eax,-0x34(%ebp)
// Same as getuint but signed - can't use getuint
// because of sign extension
static long long
getint(va_list *ap, int lflag)
{
	if (lflag >= 2)
  80063d:	83 f9 01             	cmp    $0x1,%ecx
  800640:	7e 16                	jle    800658 <vprintfmt+0x2db>
		return va_arg(*ap, long long);
  800642:	8b 45 14             	mov    0x14(%ebp),%eax
  800645:	8d 50 08             	lea    0x8(%eax),%edx
  800648:	89 55 14             	mov    %edx,0x14(%ebp)
  80064b:	8b 10                	mov    (%eax),%edx
  80064d:	8b 48 04             	mov    0x4(%eax),%ecx
  800650:	89 55 d8             	mov    %edx,-0x28(%ebp)
  800653:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800656:	eb 32                	jmp    80068a <vprintfmt+0x30d>
	else if (lflag)
  800658:	85 c9                	test   %ecx,%ecx
  80065a:	74 18                	je     800674 <vprintfmt+0x2f7>
		return va_arg(*ap, long);
  80065c:	8b 45 14             	mov    0x14(%ebp),%eax
  80065f:	8d 50 04             	lea    0x4(%eax),%edx
  800662:	89 55 14             	mov    %edx,0x14(%ebp)
  800665:	8b 00                	mov    (%eax),%eax
  800667:	89 45 d8             	mov    %eax,-0x28(%ebp)
  80066a:	89 c1                	mov    %eax,%ecx
  80066c:	c1 f9 1f             	sar    $0x1f,%ecx
  80066f:	89 4d dc             	mov    %ecx,-0x24(%ebp)
  800672:	eb 16                	jmp    80068a <vprintfmt+0x30d>
	else
		return va_arg(*ap, int);
  800674:	8b 45 14             	mov    0x14(%ebp),%eax
  800677:	8d 50 04             	lea    0x4(%eax),%edx
  80067a:	89 55 14             	mov    %edx,0x14(%ebp)
  80067d:	8b 00                	mov    (%eax),%eax
  80067f:	89 45 d8             	mov    %eax,-0x28(%ebp)
  800682:	89 c2                	mov    %eax,%edx
  800684:	c1 fa 1f             	sar    $0x1f,%edx
  800687:	89 55 dc             	mov    %edx,-0x24(%ebp)
				putch(' ', putdat);
			break;

		// (signed) decimal
		case 'd':
			num = getint(&ap, lflag);
  80068a:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  80068d:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  800690:	b8 0a 00 00 00       	mov    $0xa,%eax
			if ((long long) num < 0) {
  800695:	83 7d dc 00          	cmpl   $0x0,-0x24(%ebp)
  800699:	0f 89 9b 00 00 00    	jns    80073a <vprintfmt+0x3bd>
				putch('-', putdat);
  80069f:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006a3:	c7 04 24 2d 00 00 00 	movl   $0x2d,(%esp)
  8006aa:	ff d7                	call   *%edi
				num = -(long long) num;
  8006ac:	8b 4d d8             	mov    -0x28(%ebp),%ecx
  8006af:	8b 5d dc             	mov    -0x24(%ebp),%ebx
  8006b2:	f7 d9                	neg    %ecx
  8006b4:	83 d3 00             	adc    $0x0,%ebx
  8006b7:	f7 db                	neg    %ebx
  8006b9:	b8 0a 00 00 00       	mov    $0xa,%eax
  8006be:	eb 7a                	jmp    80073a <vprintfmt+0x3bd>
  8006c0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			base = 10;
			goto number;

		// unsigned decimal
		case 'u':
			num = getuint(&ap, lflag);
  8006c3:	89 ca                	mov    %ecx,%edx
  8006c5:	8d 45 14             	lea    0x14(%ebp),%eax
  8006c8:	e8 59 fc ff ff       	call   800326 <getuint>
  8006cd:	89 c1                	mov    %eax,%ecx
  8006cf:	89 d3                	mov    %edx,%ebx
  8006d1:	b8 0a 00 00 00       	mov    $0xa,%eax
			base = 10;
			goto number;
  8006d6:	eb 62                	jmp    80073a <vprintfmt+0x3bd>
  8006d8:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) octal
		case 'o':
			num = getuint(&ap, lflag);
  8006db:	89 ca                	mov    %ecx,%edx
  8006dd:	8d 45 14             	lea    0x14(%ebp),%eax
  8006e0:	e8 41 fc ff ff       	call   800326 <getuint>
  8006e5:	89 c1                	mov    %eax,%ecx
  8006e7:	89 d3                	mov    %edx,%ebx
  8006e9:	b8 08 00 00 00       	mov    $0x8,%eax
			base = 8;
			goto number;
  8006ee:	eb 4a                	jmp    80073a <vprintfmt+0x3bd>
  8006f0:	89 45 cc             	mov    %eax,-0x34(%ebp)
			break;
			**/

		// pointer
		case 'p':
			putch('0', putdat);
  8006f3:	89 74 24 04          	mov    %esi,0x4(%esp)
  8006f7:	c7 04 24 30 00 00 00 	movl   $0x30,(%esp)
  8006fe:	ff d7                	call   *%edi
			putch('x', putdat);
  800700:	89 74 24 04          	mov    %esi,0x4(%esp)
  800704:	c7 04 24 78 00 00 00 	movl   $0x78,(%esp)
  80070b:	ff d7                	call   *%edi
			num = (unsigned long long)
  80070d:	8b 45 14             	mov    0x14(%ebp),%eax
  800710:	8d 50 04             	lea    0x4(%eax),%edx
  800713:	89 55 14             	mov    %edx,0x14(%ebp)
  800716:	8b 08                	mov    (%eax),%ecx
  800718:	bb 00 00 00 00       	mov    $0x0,%ebx
  80071d:	b8 10 00 00 00       	mov    $0x10,%eax
				(uintptr_t) va_arg(ap, void *);
			base = 16;
			goto number;
  800722:	eb 16                	jmp    80073a <vprintfmt+0x3bd>
  800724:	89 45 cc             	mov    %eax,-0x34(%ebp)

		// (unsigned) hexadecimal
		case 'x':
			num = getuint(&ap, lflag);
  800727:	89 ca                	mov    %ecx,%edx
  800729:	8d 45 14             	lea    0x14(%ebp),%eax
  80072c:	e8 f5 fb ff ff       	call   800326 <getuint>
  800731:	89 c1                	mov    %eax,%ecx
  800733:	89 d3                	mov    %edx,%ebx
  800735:	b8 10 00 00 00       	mov    $0x10,%eax
			base = 16;
		number:
			printnum(putch, putdat, num, base, width, padc);
  80073a:	0f be 55 d4          	movsbl -0x2c(%ebp),%edx
  80073e:	89 54 24 10          	mov    %edx,0x10(%esp)
  800742:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  800745:	89 54 24 0c          	mov    %edx,0xc(%esp)
  800749:	89 44 24 08          	mov    %eax,0x8(%esp)
  80074d:	89 0c 24             	mov    %ecx,(%esp)
  800750:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  800754:	89 f2                	mov    %esi,%edx
  800756:	89 f8                	mov    %edi,%eax
  800758:	e8 d3 fa ff ff       	call   800230 <printnum>
  80075d:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800760:	e9 44 fc ff ff       	jmp    8003a9 <vprintfmt+0x2c>
  800765:	89 45 cc             	mov    %eax,-0x34(%ebp)
  800768:	8b 55 e0             	mov    -0x20(%ebp),%edx

		// escaped '%' character
		case '%':
			putch(ch, putdat);
  80076b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80076f:	89 14 24             	mov    %edx,(%esp)
  800772:	ff d7                	call   *%edi
  800774:	8b 5d cc             	mov    -0x34(%ebp),%ebx
			break;
  800777:	e9 2d fc ff ff       	jmp    8003a9 <vprintfmt+0x2c>
			
		// unrecognized escape sequence - just print it literally
		default:
			putch('%', putdat);
  80077c:	89 74 24 04          	mov    %esi,0x4(%esp)
  800780:	c7 04 24 25 00 00 00 	movl   $0x25,(%esp)
  800787:	ff d7                	call   *%edi
			for (fmt--; fmt[-1] != '%'; fmt--)
  800789:	8d 43 ff             	lea    -0x1(%ebx),%eax
  80078c:	80 38 25             	cmpb   $0x25,(%eax)
  80078f:	0f 84 14 fc ff ff    	je     8003a9 <vprintfmt+0x2c>
  800795:	89 c3                	mov    %eax,%ebx
  800797:	eb f0                	jmp    800789 <vprintfmt+0x40c>
				/* do nothing */;
			break;
		}
	}
}
  800799:	83 c4 5c             	add    $0x5c,%esp
  80079c:	5b                   	pop    %ebx
  80079d:	5e                   	pop    %esi
  80079e:	5f                   	pop    %edi
  80079f:	5d                   	pop    %ebp
  8007a0:	c3                   	ret    

008007a1 <vsnprintf>:
		*b->buf++ = ch;
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
  8007a1:	55                   	push   %ebp
  8007a2:	89 e5                	mov    %esp,%ebp
  8007a4:	83 ec 28             	sub    $0x28,%esp
  8007a7:	8b 45 08             	mov    0x8(%ebp),%eax
  8007aa:	8b 55 0c             	mov    0xc(%ebp),%edx
	struct sprintbuf b = {buf, buf+n-1, 0};

	if (buf == NULL || n < 1)
  8007ad:	85 c0                	test   %eax,%eax
  8007af:	74 04                	je     8007b5 <vsnprintf+0x14>
  8007b1:	85 d2                	test   %edx,%edx
  8007b3:	7f 07                	jg     8007bc <vsnprintf+0x1b>
  8007b5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
  8007ba:	eb 3b                	jmp    8007f7 <vsnprintf+0x56>
}

int
vsnprintf(char *buf, int n, const char *fmt, va_list ap)
{
	struct sprintbuf b = {buf, buf+n-1, 0};
  8007bc:	89 45 ec             	mov    %eax,-0x14(%ebp)
  8007bf:	8d 44 10 ff          	lea    -0x1(%eax,%edx,1),%eax
  8007c3:	89 45 f0             	mov    %eax,-0x10(%ebp)
  8007c6:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)

	if (buf == NULL || n < 1)
		return -E_INVAL;

	// print the string to the buffer
	vprintfmt((void*)sprintputch, &b, fmt, ap);
  8007cd:	8b 45 14             	mov    0x14(%ebp),%eax
  8007d0:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8007d4:	8b 45 10             	mov    0x10(%ebp),%eax
  8007d7:	89 44 24 08          	mov    %eax,0x8(%esp)
  8007db:	8d 45 ec             	lea    -0x14(%ebp),%eax
  8007de:	89 44 24 04          	mov    %eax,0x4(%esp)
  8007e2:	c7 04 24 60 03 80 00 	movl   $0x800360,(%esp)
  8007e9:	e8 8f fb ff ff       	call   80037d <vprintfmt>

	// null terminate the buffer
	*b.buf = '\0';
  8007ee:	8b 45 ec             	mov    -0x14(%ebp),%eax
  8007f1:	c6 00 00             	movb   $0x0,(%eax)

	return b.cnt;
  8007f4:	8b 45 f4             	mov    -0xc(%ebp),%eax
}
  8007f7:	c9                   	leave  
  8007f8:	c3                   	ret    

008007f9 <snprintf>:

int
snprintf(char *buf, int n, const char *fmt, ...)
{
  8007f9:	55                   	push   %ebp
  8007fa:	89 e5                	mov    %esp,%ebp
  8007fc:	83 ec 18             	sub    $0x18,%esp

	return b.cnt;
}

int
snprintf(char *buf, int n, const char *fmt, ...)
  8007ff:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;
	int rc;

	va_start(ap, fmt);
	rc = vsnprintf(buf, n, fmt, ap);
  800802:	89 44 24 0c          	mov    %eax,0xc(%esp)
  800806:	8b 45 10             	mov    0x10(%ebp),%eax
  800809:	89 44 24 08          	mov    %eax,0x8(%esp)
  80080d:	8b 45 0c             	mov    0xc(%ebp),%eax
  800810:	89 44 24 04          	mov    %eax,0x4(%esp)
  800814:	8b 45 08             	mov    0x8(%ebp),%eax
  800817:	89 04 24             	mov    %eax,(%esp)
  80081a:	e8 82 ff ff ff       	call   8007a1 <vsnprintf>
	va_end(ap);

	return rc;
}
  80081f:	c9                   	leave  
  800820:	c3                   	ret    

00800821 <printfmt>:
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
{
  800821:	55                   	push   %ebp
  800822:	89 e5                	mov    %esp,%ebp
  800824:	83 ec 18             	sub    $0x18,%esp
		}
	}
}

void
printfmt(void (*putch)(int, void*), void *putdat, const char *fmt, ...)
  800827:	8d 45 14             	lea    0x14(%ebp),%eax
{
	va_list ap;

	va_start(ap, fmt);
	vprintfmt(putch, putdat, fmt, ap);
  80082a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80082e:	8b 45 10             	mov    0x10(%ebp),%eax
  800831:	89 44 24 08          	mov    %eax,0x8(%esp)
  800835:	8b 45 0c             	mov    0xc(%ebp),%eax
  800838:	89 44 24 04          	mov    %eax,0x4(%esp)
  80083c:	8b 45 08             	mov    0x8(%ebp),%eax
  80083f:	89 04 24             	mov    %eax,(%esp)
  800842:	e8 36 fb ff ff       	call   80037d <vprintfmt>
	va_end(ap);
}
  800847:	c9                   	leave  
  800848:	c3                   	ret    
  800849:	00 00                	add    %al,(%eax)
  80084b:	00 00                	add    %al,(%eax)
  80084d:	00 00                	add    %al,(%eax)
	...

00800850 <strlen>:
// Primespipe runs 3x faster this way.
#define ASM 1

int
strlen(const char *s)
{
  800850:	55                   	push   %ebp
  800851:	89 e5                	mov    %esp,%ebp
  800853:	8b 55 08             	mov    0x8(%ebp),%edx
	int n;

	for (n = 0; *s != '\0'; s++)
  800856:	b8 00 00 00 00       	mov    $0x0,%eax
  80085b:	80 3a 00             	cmpb   $0x0,(%edx)
  80085e:	74 09                	je     800869 <strlen+0x19>
		n++;
  800860:	83 c0 01             	add    $0x1,%eax
int
strlen(const char *s)
{
	int n;

	for (n = 0; *s != '\0'; s++)
  800863:	80 3c 02 00          	cmpb   $0x0,(%edx,%eax,1)
  800867:	75 f7                	jne    800860 <strlen+0x10>
		n++;
	return n;
}
  800869:	5d                   	pop    %ebp
  80086a:	c3                   	ret    

0080086b <strnlen>:

int
strnlen(const char *s, size_t size)
{
  80086b:	55                   	push   %ebp
  80086c:	89 e5                	mov    %esp,%ebp
  80086e:	53                   	push   %ebx
  80086f:	8b 5d 08             	mov    0x8(%ebp),%ebx
  800872:	8b 4d 0c             	mov    0xc(%ebp),%ecx
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800875:	85 c9                	test   %ecx,%ecx
  800877:	74 19                	je     800892 <strnlen+0x27>
  800879:	80 3b 00             	cmpb   $0x0,(%ebx)
  80087c:	74 14                	je     800892 <strnlen+0x27>
  80087e:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
  800883:	83 c0 01             	add    $0x1,%eax
int
strnlen(const char *s, size_t size)
{
	int n;

	for (n = 0; size > 0 && *s != '\0'; s++, size--)
  800886:	39 c8                	cmp    %ecx,%eax
  800888:	74 0d                	je     800897 <strnlen+0x2c>
  80088a:	80 3c 03 00          	cmpb   $0x0,(%ebx,%eax,1)
  80088e:	75 f3                	jne    800883 <strnlen+0x18>
  800890:	eb 05                	jmp    800897 <strnlen+0x2c>
  800892:	b8 00 00 00 00       	mov    $0x0,%eax
		n++;
	return n;
}
  800897:	5b                   	pop    %ebx
  800898:	5d                   	pop    %ebp
  800899:	c3                   	ret    

0080089a <strcpy>:

char *
strcpy(char *dst, const char *src)
{
  80089a:	55                   	push   %ebp
  80089b:	89 e5                	mov    %esp,%ebp
  80089d:	53                   	push   %ebx
  80089e:	8b 45 08             	mov    0x8(%ebp),%eax
  8008a1:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  8008a4:	ba 00 00 00 00       	mov    $0x0,%edx
	char *ret;

	ret = dst;
	while ((*dst++ = *src++) != '\0')
  8008a9:	0f b6 0c 13          	movzbl (%ebx,%edx,1),%ecx
  8008ad:	88 0c 10             	mov    %cl,(%eax,%edx,1)
  8008b0:	83 c2 01             	add    $0x1,%edx
  8008b3:	84 c9                	test   %cl,%cl
  8008b5:	75 f2                	jne    8008a9 <strcpy+0xf>
		/* do nothing */;
	return ret;
}
  8008b7:	5b                   	pop    %ebx
  8008b8:	5d                   	pop    %ebp
  8008b9:	c3                   	ret    

008008ba <strncpy>:

char *
strncpy(char *dst, const char *src, size_t size) {
  8008ba:	55                   	push   %ebp
  8008bb:	89 e5                	mov    %esp,%ebp
  8008bd:	56                   	push   %esi
  8008be:	53                   	push   %ebx
  8008bf:	8b 45 08             	mov    0x8(%ebp),%eax
  8008c2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8008c5:	8b 75 10             	mov    0x10(%ebp),%esi
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8008c8:	85 f6                	test   %esi,%esi
  8008ca:	74 18                	je     8008e4 <strncpy+0x2a>
  8008cc:	b9 00 00 00 00       	mov    $0x0,%ecx
		*dst++ = *src;
  8008d1:	0f b6 1a             	movzbl (%edx),%ebx
  8008d4:	88 1c 08             	mov    %bl,(%eax,%ecx,1)
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
  8008d7:	80 3a 01             	cmpb   $0x1,(%edx)
  8008da:	83 da ff             	sbb    $0xffffffff,%edx
strncpy(char *dst, const char *src, size_t size) {
	size_t i;
	char *ret;

	ret = dst;
	for (i = 0; i < size; i++) {
  8008dd:	83 c1 01             	add    $0x1,%ecx
  8008e0:	39 ce                	cmp    %ecx,%esi
  8008e2:	77 ed                	ja     8008d1 <strncpy+0x17>
		// If strlen(src) < size, null-pad 'dst' out to 'size' chars
		if (*src != '\0')
			src++;
	}
	return ret;
}
  8008e4:	5b                   	pop    %ebx
  8008e5:	5e                   	pop    %esi
  8008e6:	5d                   	pop    %ebp
  8008e7:	c3                   	ret    

008008e8 <strlcpy>:

size_t
strlcpy(char *dst, const char *src, size_t size)
{
  8008e8:	55                   	push   %ebp
  8008e9:	89 e5                	mov    %esp,%ebp
  8008eb:	56                   	push   %esi
  8008ec:	53                   	push   %ebx
  8008ed:	8b 75 08             	mov    0x8(%ebp),%esi
  8008f0:	8b 55 0c             	mov    0xc(%ebp),%edx
  8008f3:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
  8008f6:	89 f0                	mov    %esi,%eax
  8008f8:	85 c9                	test   %ecx,%ecx
  8008fa:	74 27                	je     800923 <strlcpy+0x3b>
		while (--size > 0 && *src != '\0')
  8008fc:	83 e9 01             	sub    $0x1,%ecx
  8008ff:	74 1d                	je     80091e <strlcpy+0x36>
  800901:	0f b6 1a             	movzbl (%edx),%ebx
  800904:	84 db                	test   %bl,%bl
  800906:	74 16                	je     80091e <strlcpy+0x36>
			*dst++ = *src++;
  800908:	88 18                	mov    %bl,(%eax)
  80090a:	83 c0 01             	add    $0x1,%eax
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  80090d:	83 e9 01             	sub    $0x1,%ecx
  800910:	74 0e                	je     800920 <strlcpy+0x38>
			*dst++ = *src++;
  800912:	83 c2 01             	add    $0x1,%edx
{
	char *dst_in;

	dst_in = dst;
	if (size > 0) {
		while (--size > 0 && *src != '\0')
  800915:	0f b6 1a             	movzbl (%edx),%ebx
  800918:	84 db                	test   %bl,%bl
  80091a:	75 ec                	jne    800908 <strlcpy+0x20>
  80091c:	eb 02                	jmp    800920 <strlcpy+0x38>
  80091e:	89 f0                	mov    %esi,%eax
			*dst++ = *src++;
		*dst = '\0';
  800920:	c6 00 00             	movb   $0x0,(%eax)
  800923:	29 f0                	sub    %esi,%eax
	}
	return dst - dst_in;
}
  800925:	5b                   	pop    %ebx
  800926:	5e                   	pop    %esi
  800927:	5d                   	pop    %ebp
  800928:	c3                   	ret    

00800929 <strcmp>:

int
strcmp(const char *p, const char *q)
{
  800929:	55                   	push   %ebp
  80092a:	89 e5                	mov    %esp,%ebp
  80092c:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80092f:	8b 55 0c             	mov    0xc(%ebp),%edx
	while (*p && *p == *q)
  800932:	0f b6 01             	movzbl (%ecx),%eax
  800935:	84 c0                	test   %al,%al
  800937:	74 15                	je     80094e <strcmp+0x25>
  800939:	3a 02                	cmp    (%edx),%al
  80093b:	75 11                	jne    80094e <strcmp+0x25>
		p++, q++;
  80093d:	83 c1 01             	add    $0x1,%ecx
  800940:	83 c2 01             	add    $0x1,%edx
}

int
strcmp(const char *p, const char *q)
{
	while (*p && *p == *q)
  800943:	0f b6 01             	movzbl (%ecx),%eax
  800946:	84 c0                	test   %al,%al
  800948:	74 04                	je     80094e <strcmp+0x25>
  80094a:	3a 02                	cmp    (%edx),%al
  80094c:	74 ef                	je     80093d <strcmp+0x14>
  80094e:	0f b6 c0             	movzbl %al,%eax
  800951:	0f b6 12             	movzbl (%edx),%edx
  800954:	29 d0                	sub    %edx,%eax
		p++, q++;
	return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800956:	5d                   	pop    %ebp
  800957:	c3                   	ret    

00800958 <strncmp>:

int
strncmp(const char *p, const char *q, size_t n)
{
  800958:	55                   	push   %ebp
  800959:	89 e5                	mov    %esp,%ebp
  80095b:	53                   	push   %ebx
  80095c:	8b 55 08             	mov    0x8(%ebp),%edx
  80095f:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800962:	8b 45 10             	mov    0x10(%ebp),%eax
	while (n > 0 && *p && *p == *q)
  800965:	85 c0                	test   %eax,%eax
  800967:	74 23                	je     80098c <strncmp+0x34>
  800969:	0f b6 1a             	movzbl (%edx),%ebx
  80096c:	84 db                	test   %bl,%bl
  80096e:	74 24                	je     800994 <strncmp+0x3c>
  800970:	3a 19                	cmp    (%ecx),%bl
  800972:	75 20                	jne    800994 <strncmp+0x3c>
  800974:	83 e8 01             	sub    $0x1,%eax
  800977:	74 13                	je     80098c <strncmp+0x34>
		n--, p++, q++;
  800979:	83 c2 01             	add    $0x1,%edx
  80097c:	83 c1 01             	add    $0x1,%ecx
}

int
strncmp(const char *p, const char *q, size_t n)
{
	while (n > 0 && *p && *p == *q)
  80097f:	0f b6 1a             	movzbl (%edx),%ebx
  800982:	84 db                	test   %bl,%bl
  800984:	74 0e                	je     800994 <strncmp+0x3c>
  800986:	3a 19                	cmp    (%ecx),%bl
  800988:	74 ea                	je     800974 <strncmp+0x1c>
  80098a:	eb 08                	jmp    800994 <strncmp+0x3c>
  80098c:	b8 00 00 00 00       	mov    $0x0,%eax
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
}
  800991:	5b                   	pop    %ebx
  800992:	5d                   	pop    %ebp
  800993:	c3                   	ret    
	while (n > 0 && *p && *p == *q)
		n--, p++, q++;
	if (n == 0)
		return 0;
	else
		return (int) ((unsigned char) *p - (unsigned char) *q);
  800994:	0f b6 02             	movzbl (%edx),%eax
  800997:	0f b6 11             	movzbl (%ecx),%edx
  80099a:	29 d0                	sub    %edx,%eax
  80099c:	eb f3                	jmp    800991 <strncmp+0x39>

0080099e <strchr>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
  80099e:	55                   	push   %ebp
  80099f:	89 e5                	mov    %esp,%ebp
  8009a1:	8b 45 08             	mov    0x8(%ebp),%eax
  8009a4:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8009a8:	0f b6 10             	movzbl (%eax),%edx
  8009ab:	84 d2                	test   %dl,%dl
  8009ad:	74 15                	je     8009c4 <strchr+0x26>
		if (*s == c)
  8009af:	38 ca                	cmp    %cl,%dl
  8009b1:	75 07                	jne    8009ba <strchr+0x1c>
  8009b3:	eb 14                	jmp    8009c9 <strchr+0x2b>
  8009b5:	38 ca                	cmp    %cl,%dl
  8009b7:	90                   	nop
  8009b8:	74 0f                	je     8009c9 <strchr+0x2b>
// Return a pointer to the first occurrence of 'c' in 's',
// or a null pointer if the string has no 'c'.
char *
strchr(const char *s, char c)
{
	for (; *s; s++)
  8009ba:	83 c0 01             	add    $0x1,%eax
  8009bd:	0f b6 10             	movzbl (%eax),%edx
  8009c0:	84 d2                	test   %dl,%dl
  8009c2:	75 f1                	jne    8009b5 <strchr+0x17>
  8009c4:	b8 00 00 00 00       	mov    $0x0,%eax
		if (*s == c)
			return (char *) s;
	return 0;
}
  8009c9:	5d                   	pop    %ebp
  8009ca:	c3                   	ret    

008009cb <strfind>:

// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
  8009cb:	55                   	push   %ebp
  8009cc:	89 e5                	mov    %esp,%ebp
  8009ce:	8b 45 08             	mov    0x8(%ebp),%eax
  8009d1:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
	for (; *s; s++)
  8009d5:	0f b6 10             	movzbl (%eax),%edx
  8009d8:	84 d2                	test   %dl,%dl
  8009da:	74 18                	je     8009f4 <strfind+0x29>
		if (*s == c)
  8009dc:	38 ca                	cmp    %cl,%dl
  8009de:	75 0a                	jne    8009ea <strfind+0x1f>
  8009e0:	eb 12                	jmp    8009f4 <strfind+0x29>
  8009e2:	38 ca                	cmp    %cl,%dl
  8009e4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  8009e8:	74 0a                	je     8009f4 <strfind+0x29>
// Return a pointer to the first occurrence of 'c' in 's',
// or a pointer to the string-ending null character if the string has no 'c'.
char *
strfind(const char *s, char c)
{
	for (; *s; s++)
  8009ea:	83 c0 01             	add    $0x1,%eax
  8009ed:	0f b6 10             	movzbl (%eax),%edx
  8009f0:	84 d2                	test   %dl,%dl
  8009f2:	75 ee                	jne    8009e2 <strfind+0x17>
		if (*s == c)
			break;
	return (char *) s;
}
  8009f4:	5d                   	pop    %ebp
  8009f5:	c3                   	ret    

008009f6 <memset>:

#if ASM
void *
memset(void *v, int c, size_t n)
{
  8009f6:	55                   	push   %ebp
  8009f7:	89 e5                	mov    %esp,%ebp
  8009f9:	83 ec 0c             	sub    $0xc,%esp
  8009fc:	89 1c 24             	mov    %ebx,(%esp)
  8009ff:	89 74 24 04          	mov    %esi,0x4(%esp)
  800a03:	89 7c 24 08          	mov    %edi,0x8(%esp)
  800a07:	8b 7d 08             	mov    0x8(%ebp),%edi
  800a0a:	8b 45 0c             	mov    0xc(%ebp),%eax
  800a0d:	8b 4d 10             	mov    0x10(%ebp),%ecx
	char *p;

	if (n == 0)
  800a10:	85 c9                	test   %ecx,%ecx
  800a12:	74 30                	je     800a44 <memset+0x4e>
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800a14:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800a1a:	75 25                	jne    800a41 <memset+0x4b>
  800a1c:	f6 c1 03             	test   $0x3,%cl
  800a1f:	75 20                	jne    800a41 <memset+0x4b>
		c &= 0xFF;
  800a21:	0f b6 d0             	movzbl %al,%edx
		c = (c<<24)|(c<<16)|(c<<8)|c;
  800a24:	89 d3                	mov    %edx,%ebx
  800a26:	c1 e3 08             	shl    $0x8,%ebx
  800a29:	89 d6                	mov    %edx,%esi
  800a2b:	c1 e6 18             	shl    $0x18,%esi
  800a2e:	89 d0                	mov    %edx,%eax
  800a30:	c1 e0 10             	shl    $0x10,%eax
  800a33:	09 f0                	or     %esi,%eax
  800a35:	09 d0                	or     %edx,%eax
		asm volatile("cld; rep stosl\n"
  800a37:	09 d8                	or     %ebx,%eax
  800a39:	c1 e9 02             	shr    $0x2,%ecx
  800a3c:	fc                   	cld    
  800a3d:	f3 ab                	rep stos %eax,%es:(%edi)
{
	char *p;

	if (n == 0)
		return v;
	if ((int)v%4 == 0 && n%4 == 0) {
  800a3f:	eb 03                	jmp    800a44 <memset+0x4e>
		c = (c<<24)|(c<<16)|(c<<8)|c;
		asm volatile("cld; rep stosl\n"
			:: "D" (v), "a" (c), "c" (n/4)
			: "cc", "memory");
	} else
		asm volatile("cld; rep stosb\n"
  800a41:	fc                   	cld    
  800a42:	f3 aa                	rep stos %al,%es:(%edi)
			:: "D" (v), "a" (c), "c" (n)
			: "cc", "memory");
	return v;
}
  800a44:	89 f8                	mov    %edi,%eax
  800a46:	8b 1c 24             	mov    (%esp),%ebx
  800a49:	8b 74 24 04          	mov    0x4(%esp),%esi
  800a4d:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800a51:	89 ec                	mov    %ebp,%esp
  800a53:	5d                   	pop    %ebp
  800a54:	c3                   	ret    

00800a55 <memmove>:

void *
memmove(void *dst, const void *src, size_t n)
{
  800a55:	55                   	push   %ebp
  800a56:	89 e5                	mov    %esp,%ebp
  800a58:	83 ec 08             	sub    $0x8,%esp
  800a5b:	89 34 24             	mov    %esi,(%esp)
  800a5e:	89 7c 24 04          	mov    %edi,0x4(%esp)
  800a62:	8b 45 08             	mov    0x8(%ebp),%eax
  800a65:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const char *s;
	char *d;
	
	s = src;
  800a68:	8b 75 0c             	mov    0xc(%ebp),%esi
	d = dst;
  800a6b:	89 c7                	mov    %eax,%edi
	if (s < d && s + n > d) {
  800a6d:	39 c6                	cmp    %eax,%esi
  800a6f:	73 35                	jae    800aa6 <memmove+0x51>
  800a71:	8d 14 0e             	lea    (%esi,%ecx,1),%edx
  800a74:	39 d0                	cmp    %edx,%eax
  800a76:	73 2e                	jae    800aa6 <memmove+0x51>
		s += n;
		d += n;
  800a78:	01 cf                	add    %ecx,%edi
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800a7a:	f6 c2 03             	test   $0x3,%dl
  800a7d:	75 1b                	jne    800a9a <memmove+0x45>
  800a7f:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800a85:	75 13                	jne    800a9a <memmove+0x45>
  800a87:	f6 c1 03             	test   $0x3,%cl
  800a8a:	75 0e                	jne    800a9a <memmove+0x45>
			asm volatile("std; rep movsl\n"
  800a8c:	83 ef 04             	sub    $0x4,%edi
  800a8f:	8d 72 fc             	lea    -0x4(%edx),%esi
  800a92:	c1 e9 02             	shr    $0x2,%ecx
  800a95:	fd                   	std    
  800a96:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
	s = src;
	d = dst;
	if (s < d && s + n > d) {
		s += n;
		d += n;
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800a98:	eb 09                	jmp    800aa3 <memmove+0x4e>
			asm volatile("std; rep movsl\n"
				:: "D" (d-4), "S" (s-4), "c" (n/4) : "cc", "memory");
		else
			asm volatile("std; rep movsb\n"
  800a9a:	83 ef 01             	sub    $0x1,%edi
  800a9d:	8d 72 ff             	lea    -0x1(%edx),%esi
  800aa0:	fd                   	std    
  800aa1:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
  800aa3:	fc                   	cld    
	const char *s;
	char *d;
	
	s = src;
	d = dst;
	if (s < d && s + n > d) {
  800aa4:	eb 20                	jmp    800ac6 <memmove+0x71>
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800aa6:	f7 c6 03 00 00 00    	test   $0x3,%esi
  800aac:	75 15                	jne    800ac3 <memmove+0x6e>
  800aae:	f7 c7 03 00 00 00    	test   $0x3,%edi
  800ab4:	75 0d                	jne    800ac3 <memmove+0x6e>
  800ab6:	f6 c1 03             	test   $0x3,%cl
  800ab9:	75 08                	jne    800ac3 <memmove+0x6e>
			asm volatile("cld; rep movsl\n"
  800abb:	c1 e9 02             	shr    $0x2,%ecx
  800abe:	fc                   	cld    
  800abf:	f3 a5                	rep movsl %ds:(%esi),%es:(%edi)
			asm volatile("std; rep movsb\n"
				:: "D" (d-1), "S" (s-1), "c" (n) : "cc", "memory");
		// Some versions of GCC rely on DF being clear
		asm volatile("cld" ::: "cc");
	} else {
		if ((int)s%4 == 0 && (int)d%4 == 0 && n%4 == 0)
  800ac1:	eb 03                	jmp    800ac6 <memmove+0x71>
			asm volatile("cld; rep movsl\n"
				:: "D" (d), "S" (s), "c" (n/4) : "cc", "memory");
		else
			asm volatile("cld; rep movsb\n"
  800ac3:	fc                   	cld    
  800ac4:	f3 a4                	rep movsb %ds:(%esi),%es:(%edi)
				:: "D" (d), "S" (s), "c" (n) : "cc", "memory");
	}
	return dst;
}
  800ac6:	8b 34 24             	mov    (%esp),%esi
  800ac9:	8b 7c 24 04          	mov    0x4(%esp),%edi
  800acd:	89 ec                	mov    %ebp,%esp
  800acf:	5d                   	pop    %ebp
  800ad0:	c3                   	ret    

00800ad1 <memcpy>:

/* sigh - gcc emits references to this for structure assignments! */
/* it is *not* prototyped in inc/string.h - do not use directly. */
void *
memcpy(void *dst, void *src, size_t n)
{
  800ad1:	55                   	push   %ebp
  800ad2:	89 e5                	mov    %esp,%ebp
  800ad4:	83 ec 0c             	sub    $0xc,%esp
	return memmove(dst, src, n);
  800ad7:	8b 45 10             	mov    0x10(%ebp),%eax
  800ada:	89 44 24 08          	mov    %eax,0x8(%esp)
  800ade:	8b 45 0c             	mov    0xc(%ebp),%eax
  800ae1:	89 44 24 04          	mov    %eax,0x4(%esp)
  800ae5:	8b 45 08             	mov    0x8(%ebp),%eax
  800ae8:	89 04 24             	mov    %eax,(%esp)
  800aeb:	e8 65 ff ff ff       	call   800a55 <memmove>
}
  800af0:	c9                   	leave  
  800af1:	c3                   	ret    

00800af2 <memcmp>:

int
memcmp(const void *v1, const void *v2, size_t n)
{
  800af2:	55                   	push   %ebp
  800af3:	89 e5                	mov    %esp,%ebp
  800af5:	57                   	push   %edi
  800af6:	56                   	push   %esi
  800af7:	53                   	push   %ebx
  800af8:	8b 75 08             	mov    0x8(%ebp),%esi
  800afb:	8b 7d 0c             	mov    0xc(%ebp),%edi
  800afe:	8b 4d 10             	mov    0x10(%ebp),%ecx
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800b01:	85 c9                	test   %ecx,%ecx
  800b03:	74 36                	je     800b3b <memcmp+0x49>
		if (*s1 != *s2)
  800b05:	0f b6 06             	movzbl (%esi),%eax
  800b08:	0f b6 1f             	movzbl (%edi),%ebx
  800b0b:	38 d8                	cmp    %bl,%al
  800b0d:	74 20                	je     800b2f <memcmp+0x3d>
  800b0f:	eb 14                	jmp    800b25 <memcmp+0x33>
  800b11:	0f b6 44 16 01       	movzbl 0x1(%esi,%edx,1),%eax
  800b16:	0f b6 5c 17 01       	movzbl 0x1(%edi,%edx,1),%ebx
  800b1b:	83 c2 01             	add    $0x1,%edx
  800b1e:	83 e9 01             	sub    $0x1,%ecx
  800b21:	38 d8                	cmp    %bl,%al
  800b23:	74 12                	je     800b37 <memcmp+0x45>
			return (int) *s1 - (int) *s2;
  800b25:	0f b6 c0             	movzbl %al,%eax
  800b28:	0f b6 db             	movzbl %bl,%ebx
  800b2b:	29 d8                	sub    %ebx,%eax
  800b2d:	eb 11                	jmp    800b40 <memcmp+0x4e>
memcmp(const void *v1, const void *v2, size_t n)
{
	const uint8_t *s1 = (const uint8_t *) v1;
	const uint8_t *s2 = (const uint8_t *) v2;

	while (n-- > 0) {
  800b2f:	83 e9 01             	sub    $0x1,%ecx
  800b32:	ba 00 00 00 00       	mov    $0x0,%edx
  800b37:	85 c9                	test   %ecx,%ecx
  800b39:	75 d6                	jne    800b11 <memcmp+0x1f>
  800b3b:	b8 00 00 00 00       	mov    $0x0,%eax
			return (int) *s1 - (int) *s2;
		s1++, s2++;
	}

	return 0;
}
  800b40:	5b                   	pop    %ebx
  800b41:	5e                   	pop    %esi
  800b42:	5f                   	pop    %edi
  800b43:	5d                   	pop    %ebp
  800b44:	c3                   	ret    

00800b45 <memfind>:

void *
memfind(const void *s, int c, size_t n)
{
  800b45:	55                   	push   %ebp
  800b46:	89 e5                	mov    %esp,%ebp
  800b48:	8b 45 08             	mov    0x8(%ebp),%eax
	const void *ends = (const char *) s + n;
  800b4b:	89 c2                	mov    %eax,%edx
  800b4d:	03 55 10             	add    0x10(%ebp),%edx
	for (; s < ends; s++)
  800b50:	39 d0                	cmp    %edx,%eax
  800b52:	73 15                	jae    800b69 <memfind+0x24>
		if (*(const unsigned char *) s == (unsigned char) c)
  800b54:	0f b6 4d 0c          	movzbl 0xc(%ebp),%ecx
  800b58:	38 08                	cmp    %cl,(%eax)
  800b5a:	75 06                	jne    800b62 <memfind+0x1d>
  800b5c:	eb 0b                	jmp    800b69 <memfind+0x24>
  800b5e:	38 08                	cmp    %cl,(%eax)
  800b60:	74 07                	je     800b69 <memfind+0x24>

void *
memfind(const void *s, int c, size_t n)
{
	const void *ends = (const char *) s + n;
	for (; s < ends; s++)
  800b62:	83 c0 01             	add    $0x1,%eax
  800b65:	39 c2                	cmp    %eax,%edx
  800b67:	77 f5                	ja     800b5e <memfind+0x19>
		if (*(const unsigned char *) s == (unsigned char) c)
			break;
	return (void *) s;
}
  800b69:	5d                   	pop    %ebp
  800b6a:	c3                   	ret    

00800b6b <strtol>:

long
strtol(const char *s, char **endptr, int base)
{
  800b6b:	55                   	push   %ebp
  800b6c:	89 e5                	mov    %esp,%ebp
  800b6e:	57                   	push   %edi
  800b6f:	56                   	push   %esi
  800b70:	53                   	push   %ebx
  800b71:	83 ec 04             	sub    $0x4,%esp
  800b74:	8b 55 08             	mov    0x8(%ebp),%edx
  800b77:	8b 5d 10             	mov    0x10(%ebp),%ebx
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800b7a:	0f b6 02             	movzbl (%edx),%eax
  800b7d:	3c 20                	cmp    $0x20,%al
  800b7f:	74 04                	je     800b85 <strtol+0x1a>
  800b81:	3c 09                	cmp    $0x9,%al
  800b83:	75 0e                	jne    800b93 <strtol+0x28>
		s++;
  800b85:	83 c2 01             	add    $0x1,%edx
{
	int neg = 0;
	long val = 0;

	// gobble initial whitespace
	while (*s == ' ' || *s == '\t')
  800b88:	0f b6 02             	movzbl (%edx),%eax
  800b8b:	3c 20                	cmp    $0x20,%al
  800b8d:	74 f6                	je     800b85 <strtol+0x1a>
  800b8f:	3c 09                	cmp    $0x9,%al
  800b91:	74 f2                	je     800b85 <strtol+0x1a>
		s++;

	// plus/minus sign
	if (*s == '+')
  800b93:	3c 2b                	cmp    $0x2b,%al
  800b95:	75 0c                	jne    800ba3 <strtol+0x38>
		s++;
  800b97:	83 c2 01             	add    $0x1,%edx
  800b9a:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800ba1:	eb 15                	jmp    800bb8 <strtol+0x4d>
	else if (*s == '-')
  800ba3:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)
  800baa:	3c 2d                	cmp    $0x2d,%al
  800bac:	75 0a                	jne    800bb8 <strtol+0x4d>
		s++, neg = 1;
  800bae:	83 c2 01             	add    $0x1,%edx
  800bb1:	c7 45 f0 01 00 00 00 	movl   $0x1,-0x10(%ebp)

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800bb8:	85 db                	test   %ebx,%ebx
  800bba:	0f 94 c0             	sete   %al
  800bbd:	74 05                	je     800bc4 <strtol+0x59>
  800bbf:	83 fb 10             	cmp    $0x10,%ebx
  800bc2:	75 18                	jne    800bdc <strtol+0x71>
  800bc4:	80 3a 30             	cmpb   $0x30,(%edx)
  800bc7:	75 13                	jne    800bdc <strtol+0x71>
  800bc9:	80 7a 01 78          	cmpb   $0x78,0x1(%edx)
  800bcd:	8d 76 00             	lea    0x0(%esi),%esi
  800bd0:	75 0a                	jne    800bdc <strtol+0x71>
		s += 2, base = 16;
  800bd2:	83 c2 02             	add    $0x2,%edx
  800bd5:	bb 10 00 00 00       	mov    $0x10,%ebx
		s++;
	else if (*s == '-')
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
  800bda:	eb 15                	jmp    800bf1 <strtol+0x86>
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800bdc:	84 c0                	test   %al,%al
  800bde:	66 90                	xchg   %ax,%ax
  800be0:	74 0f                	je     800bf1 <strtol+0x86>
  800be2:	bb 0a 00 00 00       	mov    $0xa,%ebx
  800be7:	80 3a 30             	cmpb   $0x30,(%edx)
  800bea:	75 05                	jne    800bf1 <strtol+0x86>
		s++, base = 8;
  800bec:	83 c2 01             	add    $0x1,%edx
  800bef:	b3 08                	mov    $0x8,%bl
		s++, neg = 1;

	// hex or octal base prefix
	if ((base == 0 || base == 16) && (s[0] == '0' && s[1] == 'x'))
		s += 2, base = 16;
	else if (base == 0 && s[0] == '0')
  800bf1:	b8 00 00 00 00       	mov    $0x0,%eax
  800bf6:	89 de                	mov    %ebx,%esi

	// digits
	while (1) {
		int dig;

		if (*s >= '0' && *s <= '9')
  800bf8:	0f b6 0a             	movzbl (%edx),%ecx
  800bfb:	89 cf                	mov    %ecx,%edi
  800bfd:	8d 59 d0             	lea    -0x30(%ecx),%ebx
  800c00:	80 fb 09             	cmp    $0x9,%bl
  800c03:	77 08                	ja     800c0d <strtol+0xa2>
			dig = *s - '0';
  800c05:	0f be c9             	movsbl %cl,%ecx
  800c08:	83 e9 30             	sub    $0x30,%ecx
  800c0b:	eb 1e                	jmp    800c2b <strtol+0xc0>
		else if (*s >= 'a' && *s <= 'z')
  800c0d:	8d 5f 9f             	lea    -0x61(%edi),%ebx
  800c10:	80 fb 19             	cmp    $0x19,%bl
  800c13:	77 08                	ja     800c1d <strtol+0xb2>
			dig = *s - 'a' + 10;
  800c15:	0f be c9             	movsbl %cl,%ecx
  800c18:	83 e9 57             	sub    $0x57,%ecx
  800c1b:	eb 0e                	jmp    800c2b <strtol+0xc0>
		else if (*s >= 'A' && *s <= 'Z')
  800c1d:	8d 5f bf             	lea    -0x41(%edi),%ebx
  800c20:	80 fb 19             	cmp    $0x19,%bl
  800c23:	77 15                	ja     800c3a <strtol+0xcf>
			dig = *s - 'A' + 10;
  800c25:	0f be c9             	movsbl %cl,%ecx
  800c28:	83 e9 37             	sub    $0x37,%ecx
		else
			break;
		if (dig >= base)
  800c2b:	39 f1                	cmp    %esi,%ecx
  800c2d:	7d 0b                	jge    800c3a <strtol+0xcf>
			break;
		s++, val = (val * base) + dig;
  800c2f:	83 c2 01             	add    $0x1,%edx
  800c32:	0f af c6             	imul   %esi,%eax
  800c35:	8d 04 01             	lea    (%ecx,%eax,1),%eax
		// we don't properly detect overflow!
	}
  800c38:	eb be                	jmp    800bf8 <strtol+0x8d>
  800c3a:	89 c1                	mov    %eax,%ecx

	if (endptr)
  800c3c:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  800c40:	74 05                	je     800c47 <strtol+0xdc>
		*endptr = (char *) s;
  800c42:	8b 5d 0c             	mov    0xc(%ebp),%ebx
  800c45:	89 13                	mov    %edx,(%ebx)
	return (neg ? -val : val);
  800c47:	89 ca                	mov    %ecx,%edx
  800c49:	f7 da                	neg    %edx
  800c4b:	83 7d f0 00          	cmpl   $0x0,-0x10(%ebp)
  800c4f:	0f 45 c2             	cmovne %edx,%eax
}
  800c52:	83 c4 04             	add    $0x4,%esp
  800c55:	5b                   	pop    %ebx
  800c56:	5e                   	pop    %esi
  800c57:	5f                   	pop    %edi
  800c58:	5d                   	pop    %ebp
  800c59:	c3                   	ret    
	...

00800c5c <sys_cgetc>:
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}

int
sys_cgetc(void)
{
  800c5c:	55                   	push   %ebp
  800c5d:	89 e5                	mov    %esp,%ebp
  800c5f:	83 ec 0c             	sub    $0xc,%esp
  800c62:	89 1c 24             	mov    %ebx,(%esp)
  800c65:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c69:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800c6d:	ba 00 00 00 00       	mov    $0x0,%edx
  800c72:	b8 01 00 00 00       	mov    $0x1,%eax
  800c77:	89 d1                	mov    %edx,%ecx
  800c79:	89 d3                	mov    %edx,%ebx
  800c7b:	89 d7                	mov    %edx,%edi
  800c7d:	89 d6                	mov    %edx,%esi
  800c7f:	cd 30                	int    $0x30

int
sys_cgetc(void)
{
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}
  800c81:	8b 1c 24             	mov    (%esp),%ebx
  800c84:	8b 74 24 04          	mov    0x4(%esp),%esi
  800c88:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800c8c:	89 ec                	mov    %ebp,%esp
  800c8e:	5d                   	pop    %ebp
  800c8f:	c3                   	ret    

00800c90 <sys_cputs>:
	return ret;
}

void
sys_cputs(const char *s, size_t len)
{
  800c90:	55                   	push   %ebp
  800c91:	89 e5                	mov    %esp,%ebp
  800c93:	83 ec 0c             	sub    $0xc,%esp
  800c96:	89 1c 24             	mov    %ebx,(%esp)
  800c99:	89 74 24 04          	mov    %esi,0x4(%esp)
  800c9d:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800ca1:	b8 00 00 00 00       	mov    $0x0,%eax
  800ca6:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ca9:	8b 55 08             	mov    0x8(%ebp),%edx
  800cac:	89 c3                	mov    %eax,%ebx
  800cae:	89 c7                	mov    %eax,%edi
  800cb0:	89 c6                	mov    %eax,%esi
  800cb2:	cd 30                	int    $0x30

void
sys_cputs(const char *s, size_t len)
{
	syscall(SYS_cputs, 0, (uint32_t)s, len, 0, 0, 0);
}
  800cb4:	8b 1c 24             	mov    (%esp),%ebx
  800cb7:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cbb:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800cbf:	89 ec                	mov    %ebp,%esp
  800cc1:	5d                   	pop    %ebp
  800cc2:	c3                   	ret    

00800cc3 <sys_ns_recv>:
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}

int
sys_ns_recv(void *pkt, uint32_t len)
{
  800cc3:	55                   	push   %ebp
  800cc4:	89 e5                	mov    %esp,%ebp
  800cc6:	83 ec 0c             	sub    $0xc,%esp
  800cc9:	89 1c 24             	mov    %ebx,(%esp)
  800ccc:	89 74 24 04          	mov    %esi,0x4(%esp)
  800cd0:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800cd4:	bb 00 00 00 00       	mov    $0x0,%ebx
  800cd9:	b8 10 00 00 00       	mov    $0x10,%eax
  800cde:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ce1:	8b 55 08             	mov    0x8(%ebp),%edx
  800ce4:	89 df                	mov    %ebx,%edi
  800ce6:	89 de                	mov    %ebx,%esi
  800ce8:	cd 30                	int    $0x30

int
sys_ns_recv(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_recv, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800cea:	8b 1c 24             	mov    (%esp),%ebx
  800ced:	8b 74 24 04          	mov    0x4(%esp),%esi
  800cf1:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800cf5:	89 ec                	mov    %ebp,%esp
  800cf7:	5d                   	pop    %ebp
  800cf8:	c3                   	ret    

00800cf9 <sys_ns_send>:
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}

int
sys_ns_send(void *pkt, uint32_t len)
{
  800cf9:	55                   	push   %ebp
  800cfa:	89 e5                	mov    %esp,%ebp
  800cfc:	83 ec 0c             	sub    $0xc,%esp
  800cff:	89 1c 24             	mov    %ebx,(%esp)
  800d02:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d06:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d0a:	bb 00 00 00 00       	mov    $0x0,%ebx
  800d0f:	b8 0f 00 00 00       	mov    $0xf,%eax
  800d14:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800d17:	8b 55 08             	mov    0x8(%ebp),%edx
  800d1a:	89 df                	mov    %ebx,%edi
  800d1c:	89 de                	mov    %ebx,%esi
  800d1e:	cd 30                	int    $0x30

int
sys_ns_send(void *pkt, uint32_t len)
{
  return syscall(SYS_ns_send, 0, (uint32_t)pkt, len, 0, 0, 0);
}
  800d20:	8b 1c 24             	mov    (%esp),%ebx
  800d23:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d27:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d2b:	89 ec                	mov    %ebp,%esp
  800d2d:	5d                   	pop    %ebp
  800d2e:	c3                   	ret    

00800d2f <sys_time_msec>:
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}

unsigned int
sys_time_msec(void)
{
  800d2f:	55                   	push   %ebp
  800d30:	89 e5                	mov    %esp,%ebp
  800d32:	83 ec 0c             	sub    $0xc,%esp
  800d35:	89 1c 24             	mov    %ebx,(%esp)
  800d38:	89 74 24 04          	mov    %esi,0x4(%esp)
  800d3c:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d40:	ba 00 00 00 00       	mov    $0x0,%edx
  800d45:	b8 0e 00 00 00       	mov    $0xe,%eax
  800d4a:	89 d1                	mov    %edx,%ecx
  800d4c:	89 d3                	mov    %edx,%ebx
  800d4e:	89 d7                	mov    %edx,%edi
  800d50:	89 d6                	mov    %edx,%esi
  800d52:	cd 30                	int    $0x30

unsigned int
sys_time_msec(void)
{
	return (unsigned int) syscall(SYS_time_msec, 0, 0, 0, 0, 0, 0);
}
  800d54:	8b 1c 24             	mov    (%esp),%ebx
  800d57:	8b 74 24 04          	mov    0x4(%esp),%esi
  800d5b:	8b 7c 24 08          	mov    0x8(%esp),%edi
  800d5f:	89 ec                	mov    %ebp,%esp
  800d61:	5d                   	pop    %ebp
  800d62:	c3                   	ret    

00800d63 <sys_ipc_recv>:
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}

int
sys_ipc_recv(void *dstva)
{
  800d63:	55                   	push   %ebp
  800d64:	89 e5                	mov    %esp,%ebp
  800d66:	83 ec 38             	sub    $0x38,%esp
  800d69:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800d6c:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800d6f:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800d72:	b9 00 00 00 00       	mov    $0x0,%ecx
  800d77:	b8 0d 00 00 00       	mov    $0xd,%eax
  800d7c:	8b 55 08             	mov    0x8(%ebp),%edx
  800d7f:	89 cb                	mov    %ecx,%ebx
  800d81:	89 cf                	mov    %ecx,%edi
  800d83:	89 ce                	mov    %ecx,%esi
  800d85:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800d87:	85 c0                	test   %eax,%eax
  800d89:	7e 28                	jle    800db3 <sys_ipc_recv+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  800d8b:	89 44 24 10          	mov    %eax,0x10(%esp)
  800d8f:	c7 44 24 0c 0d 00 00 	movl   $0xd,0xc(%esp)
  800d96:	00 
  800d97:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800d9e:	00 
  800d9f:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800da6:	00 
  800da7:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800dae:	e8 01 1b 00 00       	call   8028b4 <_panic>

int
sys_ipc_recv(void *dstva)
{
	return syscall(SYS_ipc_recv, 1, (uint32_t)dstva, 0, 0, 0, 0);
}
  800db3:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800db6:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800db9:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800dbc:	89 ec                	mov    %ebp,%esp
  800dbe:	5d                   	pop    %ebp
  800dbf:	c3                   	ret    

00800dc0 <sys_ipc_try_send>:
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
  800dc0:	55                   	push   %ebp
  800dc1:	89 e5                	mov    %esp,%ebp
  800dc3:	83 ec 38             	sub    $0x38,%esp
  800dc6:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800dc9:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800dcc:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800dcf:	be 00 00 00 00       	mov    $0x0,%esi
  800dd4:	b8 0c 00 00 00       	mov    $0xc,%eax
  800dd9:	8b 7d 14             	mov    0x14(%ebp),%edi
  800ddc:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800ddf:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800de2:	8b 55 08             	mov    0x8(%ebp),%edx
  800de5:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800de7:	85 c0                	test   %eax,%eax
  800de9:	7e 28                	jle    800e13 <sys_ipc_try_send+0x53>
		panic("syscall %d returned %d (> 0)", num, ret);
  800deb:	89 44 24 10          	mov    %eax,0x10(%esp)
  800def:	c7 44 24 0c 0c 00 00 	movl   $0xc,0xc(%esp)
  800df6:	00 
  800df7:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800dfe:	00 
  800dff:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e06:	00 
  800e07:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800e0e:	e8 a1 1a 00 00       	call   8028b4 <_panic>

int
sys_ipc_try_send(envid_t envid, uint32_t value, void *srcva, int perm)
{
	return syscall(SYS_ipc_try_send, 1, envid, value, (uint32_t) srcva, perm, 0);
}
  800e13:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e16:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e19:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e1c:	89 ec                	mov    %ebp,%esp
  800e1e:	5d                   	pop    %ebp
  800e1f:	c3                   	ret    

00800e20 <sys_env_set_pgfault_upcall>:
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
  800e20:	55                   	push   %ebp
  800e21:	89 e5                	mov    %esp,%ebp
  800e23:	83 ec 38             	sub    $0x38,%esp
  800e26:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e29:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e2c:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e2f:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e34:	b8 0a 00 00 00       	mov    $0xa,%eax
  800e39:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e3c:	8b 55 08             	mov    0x8(%ebp),%edx
  800e3f:	89 df                	mov    %ebx,%edi
  800e41:	89 de                	mov    %ebx,%esi
  800e43:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800e45:	85 c0                	test   %eax,%eax
  800e47:	7e 28                	jle    800e71 <sys_env_set_pgfault_upcall+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800e49:	89 44 24 10          	mov    %eax,0x10(%esp)
  800e4d:	c7 44 24 0c 0a 00 00 	movl   $0xa,0xc(%esp)
  800e54:	00 
  800e55:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800e5c:	00 
  800e5d:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800e64:	00 
  800e65:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800e6c:	e8 43 1a 00 00       	call   8028b4 <_panic>

int
sys_env_set_pgfault_upcall(envid_t envid, void *upcall)
{
	return syscall(SYS_env_set_pgfault_upcall, 1, envid, (uint32_t) upcall, 0, 0, 0);
}
  800e71:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800e74:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800e77:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800e7a:	89 ec                	mov    %ebp,%esp
  800e7c:	5d                   	pop    %ebp
  800e7d:	c3                   	ret    

00800e7e <sys_env_set_trapframe>:
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
  800e7e:	55                   	push   %ebp
  800e7f:	89 e5                	mov    %esp,%ebp
  800e81:	83 ec 38             	sub    $0x38,%esp
  800e84:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800e87:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800e8a:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800e8d:	bb 00 00 00 00       	mov    $0x0,%ebx
  800e92:	b8 09 00 00 00       	mov    $0x9,%eax
  800e97:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800e9a:	8b 55 08             	mov    0x8(%ebp),%edx
  800e9d:	89 df                	mov    %ebx,%edi
  800e9f:	89 de                	mov    %ebx,%esi
  800ea1:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800ea3:	85 c0                	test   %eax,%eax
  800ea5:	7e 28                	jle    800ecf <sys_env_set_trapframe+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800ea7:	89 44 24 10          	mov    %eax,0x10(%esp)
  800eab:	c7 44 24 0c 09 00 00 	movl   $0x9,0xc(%esp)
  800eb2:	00 
  800eb3:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800eba:	00 
  800ebb:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800ec2:	00 
  800ec3:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800eca:	e8 e5 19 00 00       	call   8028b4 <_panic>

int
sys_env_set_trapframe(envid_t envid, struct Trapframe *tf)
{
	return syscall(SYS_env_set_trapframe, 1, envid, (uint32_t) tf, 0, 0, 0);
}
  800ecf:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800ed2:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800ed5:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ed8:	89 ec                	mov    %ebp,%esp
  800eda:	5d                   	pop    %ebp
  800edb:	c3                   	ret    

00800edc <sys_env_set_status>:

// sys_exofork is inlined in lib.h

int
sys_env_set_status(envid_t envid, int status)
{
  800edc:	55                   	push   %ebp
  800edd:	89 e5                	mov    %esp,%ebp
  800edf:	83 ec 38             	sub    $0x38,%esp
  800ee2:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800ee5:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800ee8:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800eeb:	bb 00 00 00 00       	mov    $0x0,%ebx
  800ef0:	b8 08 00 00 00       	mov    $0x8,%eax
  800ef5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800ef8:	8b 55 08             	mov    0x8(%ebp),%edx
  800efb:	89 df                	mov    %ebx,%edi
  800efd:	89 de                	mov    %ebx,%esi
  800eff:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f01:	85 c0                	test   %eax,%eax
  800f03:	7e 28                	jle    800f2d <sys_env_set_status+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f05:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f09:	c7 44 24 0c 08 00 00 	movl   $0x8,0xc(%esp)
  800f10:	00 
  800f11:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800f18:	00 
  800f19:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f20:	00 
  800f21:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800f28:	e8 87 19 00 00       	call   8028b4 <_panic>

int
sys_env_set_status(envid_t envid, int status)
{
	return syscall(SYS_env_set_status, 1, envid, status, 0, 0, 0);
}
  800f2d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f30:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f33:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f36:	89 ec                	mov    %ebp,%esp
  800f38:	5d                   	pop    %ebp
  800f39:	c3                   	ret    

00800f3a <sys_page_unmap>:
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}

int
sys_page_unmap(envid_t envid, void *va)
{
  800f3a:	55                   	push   %ebp
  800f3b:	89 e5                	mov    %esp,%ebp
  800f3d:	83 ec 38             	sub    $0x38,%esp
  800f40:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800f43:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800f46:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800f49:	bb 00 00 00 00       	mov    $0x0,%ebx
  800f4e:	b8 06 00 00 00       	mov    $0x6,%eax
  800f53:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800f56:	8b 55 08             	mov    0x8(%ebp),%edx
  800f59:	89 df                	mov    %ebx,%edi
  800f5b:	89 de                	mov    %ebx,%esi
  800f5d:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800f5f:	85 c0                	test   %eax,%eax
  800f61:	7e 28                	jle    800f8b <sys_page_unmap+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800f63:	89 44 24 10          	mov    %eax,0x10(%esp)
  800f67:	c7 44 24 0c 06 00 00 	movl   $0x6,0xc(%esp)
  800f6e:	00 
  800f6f:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800f76:	00 
  800f77:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800f7e:	00 
  800f7f:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800f86:	e8 29 19 00 00       	call   8028b4 <_panic>

int
sys_page_unmap(envid_t envid, void *va)
{
	return syscall(SYS_page_unmap, 1, envid, (uint32_t) va, 0, 0, 0);
}
  800f8b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800f8e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800f91:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800f94:	89 ec                	mov    %ebp,%esp
  800f96:	5d                   	pop    %ebp
  800f97:	c3                   	ret    

00800f98 <sys_page_map>:
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
  800f98:	55                   	push   %ebp
  800f99:	89 e5                	mov    %esp,%ebp
  800f9b:	83 ec 38             	sub    $0x38,%esp
  800f9e:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fa1:	89 75 f8             	mov    %esi,-0x8(%ebp)
  800fa4:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  800fa7:	b8 05 00 00 00       	mov    $0x5,%eax
  800fac:	8b 75 18             	mov    0x18(%ebp),%esi
  800faf:	8b 7d 14             	mov    0x14(%ebp),%edi
  800fb2:	8b 5d 10             	mov    0x10(%ebp),%ebx
  800fb5:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  800fb8:	8b 55 08             	mov    0x8(%ebp),%edx
  800fbb:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  800fbd:	85 c0                	test   %eax,%eax
  800fbf:	7e 28                	jle    800fe9 <sys_page_map+0x51>
		panic("syscall %d returned %d (> 0)", num, ret);
  800fc1:	89 44 24 10          	mov    %eax,0x10(%esp)
  800fc5:	c7 44 24 0c 05 00 00 	movl   $0x5,0xc(%esp)
  800fcc:	00 
  800fcd:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  800fd4:	00 
  800fd5:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  800fdc:	00 
  800fdd:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  800fe4:	e8 cb 18 00 00       	call   8028b4 <_panic>

int
sys_page_map(envid_t srcenv, void *srcva, envid_t dstenv, void *dstva, int perm)
{
	return syscall(SYS_page_map, 1, srcenv, (uint32_t) srcva, dstenv, (uint32_t) dstva, perm);
}
  800fe9:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  800fec:	8b 75 f8             	mov    -0x8(%ebp),%esi
  800fef:	8b 7d fc             	mov    -0x4(%ebp),%edi
  800ff2:	89 ec                	mov    %ebp,%esp
  800ff4:	5d                   	pop    %ebp
  800ff5:	c3                   	ret    

00800ff6 <sys_page_alloc>:
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
  800ff6:	55                   	push   %ebp
  800ff7:	89 e5                	mov    %esp,%ebp
  800ff9:	83 ec 38             	sub    $0x38,%esp
  800ffc:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  800fff:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801002:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801005:	be 00 00 00 00       	mov    $0x0,%esi
  80100a:	b8 04 00 00 00       	mov    $0x4,%eax
  80100f:	8b 5d 10             	mov    0x10(%ebp),%ebx
  801012:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  801015:	8b 55 08             	mov    0x8(%ebp),%edx
  801018:	89 f7                	mov    %esi,%edi
  80101a:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  80101c:	85 c0                	test   %eax,%eax
  80101e:	7e 28                	jle    801048 <sys_page_alloc+0x52>
		panic("syscall %d returned %d (> 0)", num, ret);
  801020:	89 44 24 10          	mov    %eax,0x10(%esp)
  801024:	c7 44 24 0c 04 00 00 	movl   $0x4,0xc(%esp)
  80102b:	00 
  80102c:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  801033:	00 
  801034:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  80103b:	00 
  80103c:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  801043:	e8 6c 18 00 00       	call   8028b4 <_panic>

int
sys_page_alloc(envid_t envid, void *va, int perm)
{
	return syscall(SYS_page_alloc, 1, envid, (uint32_t) va, perm, 0, 0);
}
  801048:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80104b:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80104e:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801051:	89 ec                	mov    %ebp,%esp
  801053:	5d                   	pop    %ebp
  801054:	c3                   	ret    

00801055 <sys_yield>:
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}

void
sys_yield(void)
{
  801055:	55                   	push   %ebp
  801056:	89 e5                	mov    %esp,%ebp
  801058:	83 ec 0c             	sub    $0xc,%esp
  80105b:	89 1c 24             	mov    %ebx,(%esp)
  80105e:	89 74 24 04          	mov    %esi,0x4(%esp)
  801062:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  801066:	ba 00 00 00 00       	mov    $0x0,%edx
  80106b:	b8 0b 00 00 00       	mov    $0xb,%eax
  801070:	89 d1                	mov    %edx,%ecx
  801072:	89 d3                	mov    %edx,%ebx
  801074:	89 d7                	mov    %edx,%edi
  801076:	89 d6                	mov    %edx,%esi
  801078:	cd 30                	int    $0x30

void
sys_yield(void)
{
	syscall(SYS_yield, 0, 0, 0, 0, 0, 0);
}
  80107a:	8b 1c 24             	mov    (%esp),%ebx
  80107d:	8b 74 24 04          	mov    0x4(%esp),%esi
  801081:	8b 7c 24 08          	mov    0x8(%esp),%edi
  801085:	89 ec                	mov    %ebp,%esp
  801087:	5d                   	pop    %ebp
  801088:	c3                   	ret    

00801089 <sys_getenvid>:
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}

envid_t
sys_getenvid(void)
{
  801089:	55                   	push   %ebp
  80108a:	89 e5                	mov    %esp,%ebp
  80108c:	83 ec 0c             	sub    $0xc,%esp
  80108f:	89 1c 24             	mov    %ebx,(%esp)
  801092:	89 74 24 04          	mov    %esi,0x4(%esp)
  801096:	89 7c 24 08          	mov    %edi,0x8(%esp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  80109a:	ba 00 00 00 00       	mov    $0x0,%edx
  80109f:	b8 02 00 00 00       	mov    $0x2,%eax
  8010a4:	89 d1                	mov    %edx,%ecx
  8010a6:	89 d3                	mov    %edx,%ebx
  8010a8:	89 d7                	mov    %edx,%edi
  8010aa:	89 d6                	mov    %edx,%esi
  8010ac:	cd 30                	int    $0x30

envid_t
sys_getenvid(void)
{
	 return syscall(SYS_getenvid, 0, 0, 0, 0, 0, 0);
}
  8010ae:	8b 1c 24             	mov    (%esp),%ebx
  8010b1:	8b 74 24 04          	mov    0x4(%esp),%esi
  8010b5:	8b 7c 24 08          	mov    0x8(%esp),%edi
  8010b9:	89 ec                	mov    %ebp,%esp
  8010bb:	5d                   	pop    %ebp
  8010bc:	c3                   	ret    

008010bd <sys_env_destroy>:
	return syscall(SYS_cgetc, 0, 0, 0, 0, 0, 0);
}

int
sys_env_destroy(envid_t envid)
{
  8010bd:	55                   	push   %ebp
  8010be:	89 e5                	mov    %esp,%ebp
  8010c0:	83 ec 38             	sub    $0x38,%esp
  8010c3:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8010c6:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8010c9:	89 7d fc             	mov    %edi,-0x4(%ebp)
	// 
	// The last clause tells the assembler that this can
	// potentially change the condition codes and arbitrary
	// memory locations.

	asm volatile("int %1\n"
  8010cc:	b9 00 00 00 00       	mov    $0x0,%ecx
  8010d1:	b8 03 00 00 00       	mov    $0x3,%eax
  8010d6:	8b 55 08             	mov    0x8(%ebp),%edx
  8010d9:	89 cb                	mov    %ecx,%ebx
  8010db:	89 cf                	mov    %ecx,%edi
  8010dd:	89 ce                	mov    %ecx,%esi
  8010df:	cd 30                	int    $0x30
		  "b" (a3),
		  "D" (a4),
		  "S" (a5)
		: "cc", "memory");
	
	if(check && ret > 0)
  8010e1:	85 c0                	test   %eax,%eax
  8010e3:	7e 28                	jle    80110d <sys_env_destroy+0x50>
		panic("syscall %d returned %d (> 0)", num, ret);
  8010e5:	89 44 24 10          	mov    %eax,0x10(%esp)
  8010e9:	c7 44 24 0c 03 00 00 	movl   $0x3,0xc(%esp)
  8010f0:	00 
  8010f1:	c7 44 24 08 6b 30 80 	movl   $0x80306b,0x8(%esp)
  8010f8:	00 
  8010f9:	c7 44 24 04 23 00 00 	movl   $0x23,0x4(%esp)
  801100:	00 
  801101:	c7 04 24 88 30 80 00 	movl   $0x803088,(%esp)
  801108:	e8 a7 17 00 00       	call   8028b4 <_panic>

int
sys_env_destroy(envid_t envid)
{
	return syscall(SYS_env_destroy, 1, envid, 0, 0, 0, 0);
}
  80110d:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801110:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801113:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801116:	89 ec                	mov    %ebp,%esp
  801118:	5d                   	pop    %ebp
  801119:	c3                   	ret    
  80111a:	00 00                	add    %al,(%eax)
  80111c:	00 00                	add    %al,(%eax)
	...

00801120 <sfork>:
}

// Challenge!
int
sfork(void)
{
  801120:	55                   	push   %ebp
  801121:	89 e5                	mov    %esp,%ebp
  801123:	83 ec 18             	sub    $0x18,%esp
	panic("sfork not implemented");
  801126:	c7 44 24 08 96 30 80 	movl   $0x803096,0x8(%esp)
  80112d:	00 
  80112e:	c7 44 24 04 9a 00 00 	movl   $0x9a,0x4(%esp)
  801135:	00 
  801136:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  80113d:	e8 72 17 00 00       	call   8028b4 <_panic>

00801142 <fork>:
//   Neither user exception stack should ever be marked copy-on-write,
//   so you must allocate a new page for the child's user exception stack.
//
envid_t
fork(void)
{
  801142:	55                   	push   %ebp
  801143:	89 e5                	mov    %esp,%ebp
  801145:	57                   	push   %edi
  801146:	56                   	push   %esi
  801147:	53                   	push   %ebx
  801148:	83 ec 3c             	sub    $0x3c,%esp
    int r   = 0;
    int i;
    envid_t childId = 0;
	// LAB 4: Your code here.
    // Setup parent process pgfault handler.
    set_pgfault_handler(pgfault);
  80114b:	c7 04 24 ac 13 80 00 	movl   $0x8013ac,(%esp)
  801152:	e8 c1 17 00 00       	call   802918 <set_pgfault_handler>
static __inline envid_t sys_exofork(void) __attribute__((always_inline));
static __inline envid_t
sys_exofork(void)
{
	envid_t ret;
	__asm __volatile("int %2"
  801157:	ba 07 00 00 00       	mov    $0x7,%edx
  80115c:	89 d0                	mov    %edx,%eax
  80115e:	cd 30                	int    $0x30
  801160:	89 45 d8             	mov    %eax,-0x28(%ebp)
    childId=sys_exofork();

    if (childId<0) {
  801163:	85 c0                	test   %eax,%eax
  801165:	79 20                	jns    801187 <fork+0x45>
        panic("Parent: sys_exofork. Error: 0x%x\n", childId);
  801167:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80116b:	c7 44 24 08 1c 31 80 	movl   $0x80311c,0x8(%esp)
  801172:	00 
  801173:	c7 44 24 04 7b 00 00 	movl   $0x7b,0x4(%esp)
  80117a:	00 
  80117b:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  801182:	e8 2d 17 00 00       	call   8028b4 <_panic>
    } else if (childId>0) {
  801187:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  80118b:	0f 8e f3 01 00 00    	jle    801384 <fork+0x242>
      // Setup child process' pgfault handler.
      if ((r=sys_env_set_pgfault_upcall(childId, _pgfault_upcall))) {
  801191:	c7 44 24 04 88 29 80 	movl   $0x802988,0x4(%esp)
  801198:	00 
  801199:	8b 45 d8             	mov    -0x28(%ebp),%eax
  80119c:	89 04 24             	mov    %eax,(%esp)
  80119f:	e8 7c fc ff ff       	call   800e20 <sys_env_set_pgfault_upcall>
  8011a4:	85 c0                	test   %eax,%eax
  8011a6:	74 20                	je     8011c8 <fork+0x86>
          panic("Child: sys_env_set_pgfault_upcall. Error: %d\n", r);
  8011a8:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8011ac:	c7 44 24 08 40 31 80 	movl   $0x803140,0x8(%esp)
  8011b3:	00 
  8011b4:	c7 44 24 04 7f 00 00 	movl   $0x7f,0x4(%esp)
  8011bb:	00 
  8011bc:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  8011c3:	e8 ec 16 00 00       	call   8028b4 <_panic>
      }
      
      // Setup child's Image.
      // Allocate page for child's user exception stack.
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
  8011c8:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  8011cf:	00 
  8011d0:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  8011d7:	ee 
  8011d8:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8011db:	89 04 24             	mov    %eax,(%esp)
  8011de:	e8 13 fe ff ff       	call   800ff6 <sys_page_alloc>
  8011e3:	85 c0                	test   %eax,%eax
  8011e5:	79 20                	jns    801207 <fork+0xc5>
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
  8011e7:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8011eb:	c7 44 24 08 70 31 80 	movl   $0x803170,0x8(%esp)
  8011f2:	00 
  8011f3:	c7 44 24 04 85 00 00 	movl   $0x85,0x4(%esp)
  8011fa:	00 
  8011fb:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  801202:	e8 ad 16 00 00       	call   8028b4 <_panic>
  801207:	be 00 00 80 00       	mov    $0x800000,%esi
  80120c:	bb 00 00 80 00       	mov    $0x800000,%ebx
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
        if (vpd[VPD(i)]&PTE_P)
  801211:	bf 00 d0 7b ef       	mov    $0xef7bd000,%edi
  801216:	89 f0                	mov    %esi,%eax
  801218:	c1 e8 16             	shr    $0x16,%eax
  80121b:	8b 04 87             	mov    (%edi,%eax,4),%eax
  80121e:	a8 01                	test   $0x1,%al
  801220:	0f 84 13 01 00 00    	je     801339 <fork+0x1f7>
// 
static int
duppage(envid_t envid, unsigned pn)
{
	int r           = 0;
  int perm        = vpt[VPN(pn)]&PTE_USER;
  801226:	89 f0                	mov    %esi,%eax
  801228:	c1 e8 0c             	shr    $0xc,%eax
  80122b:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
  801232:	89 45 e4             	mov    %eax,-0x1c(%ebp)
  801235:	25 07 0e 00 00       	and    $0xe07,%eax
  80123a:	89 45 e0             	mov    %eax,-0x20(%ebp)
  envid_t env_id  = sys_getenvid();
  80123d:	e8 47 fe ff ff       	call   801089 <sys_getenvid>
  801242:	89 45 dc             	mov    %eax,-0x24(%ebp)

	// LAB 4: Your code here.
  if ((perm&PTE_P) && (perm&PTE_W || perm&PTE_COW) && (!(perm&PTE_SHARE))) {
  801245:	f6 45 e4 01          	testb  $0x1,-0x1c(%ebp)
  801249:	0f 84 ea 00 00 00    	je     801339 <fork+0x1f7>
  80124f:	f7 45 e0 02 08 00 00 	testl  $0x802,-0x20(%ebp)
  801256:	0f 84 9d 00 00 00    	je     8012f9 <fork+0x1b7>
  80125c:	f7 45 e0 00 04 00 00 	testl  $0x400,-0x20(%ebp)
  801263:	0f 85 90 00 00 00    	jne    8012f9 <fork+0x1b7>
    perm    &= (~PTE_W);
  801269:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80126c:	83 e0 fd             	and    $0xfffffffd,%eax
    perm    |= PTE_COW;
  80126f:	80 cc 08             	or     $0x8,%ah
  801272:	89 45 e4             	mov    %eax,-0x1c(%ebp)
    
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  801275:	89 75 e0             	mov    %esi,-0x20(%ebp)
  801278:	89 44 24 10          	mov    %eax,0x10(%esp)
  80127c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801280:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801283:	89 44 24 08          	mov    %eax,0x8(%esp)
  801287:	89 74 24 04          	mov    %esi,0x4(%esp)
  80128b:	8b 45 dc             	mov    -0x24(%ebp),%eax
  80128e:	89 04 24             	mov    %eax,(%esp)
  801291:	e8 02 fd ff ff       	call   800f98 <sys_page_map>
  801296:	85 c0                	test   %eax,%eax
  801298:	79 1b                	jns    8012b5 <fork+0x173>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80129a:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80129e:	89 74 24 08          	mov    %esi,0x8(%esp)
  8012a2:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012a5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012a9:	c7 04 24 98 31 80 00 	movl   $0x803198,(%esp)
  8012b0:	e8 14 ef ff ff       	call   8001c9 <cprintf>
    // Map permissions back to parent on COW.
    if ((r=sys_page_map(envid, (void *)pn, env_id, (void *)pn, perm))<0)
  8012b5:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8012b8:	89 44 24 10          	mov    %eax,0x10(%esp)
  8012bc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012bf:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8012c3:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012c6:	89 44 24 08          	mov    %eax,0x8(%esp)
  8012ca:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012cd:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012d1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8012d4:	89 04 24             	mov    %eax,(%esp)
  8012d7:	e8 bc fc ff ff       	call   800f98 <sys_page_map>
  8012dc:	85 c0                	test   %eax,%eax
  8012de:	79 59                	jns    801339 <fork+0x1f7>
      cprintf("[0x%x] Mapping to PARENT: sys_page_map. Error: %d\n", env_id, r);
  8012e0:	89 44 24 08          	mov    %eax,0x8(%esp)
  8012e4:	8b 45 dc             	mov    -0x24(%ebp),%eax
  8012e7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8012eb:	c7 04 24 d8 31 80 00 	movl   $0x8031d8,(%esp)
  8012f2:	e8 d2 ee ff ff       	call   8001c9 <cprintf>
  8012f7:	eb 40                	jmp    801339 <fork+0x1f7>
  } else if (perm&PTE_P){
    if ((r=sys_page_map(env_id, (void *)pn, envid, (void *)pn, perm))<0)
  8012f9:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8012fc:	89 44 24 10          	mov    %eax,0x10(%esp)
  801300:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801304:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801307:	89 44 24 08          	mov    %eax,0x8(%esp)
  80130b:	89 74 24 04          	mov    %esi,0x4(%esp)
  80130f:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801312:	89 04 24             	mov    %eax,(%esp)
  801315:	e8 7e fc ff ff       	call   800f98 <sys_page_map>
  80131a:	85 c0                	test   %eax,%eax
  80131c:	79 1b                	jns    801339 <fork+0x1f7>
      cprintf("[0x%x] Mapping to CHILD: sys_page_map. Address 0x%x. Error: %d\n", env_id, pn, r);
  80131e:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801322:	89 74 24 08          	mov    %esi,0x8(%esp)
  801326:	8b 45 dc             	mov    -0x24(%ebp),%eax
  801329:	89 44 24 04          	mov    %eax,0x4(%esp)
  80132d:	c7 04 24 98 31 80 00 	movl   $0x803198,(%esp)
  801334:	e8 90 ee ff ff       	call   8001c9 <cprintf>
      if ((r=sys_page_alloc(childId, (void *)(UXSTACKTOP-PGSIZE), PTE_U|PTE_P|PTE_W))<0) {
          panic("Parent: sys_page_alloc. Error: 0x%x\n", r);           
      }

      // Copy Parent's address space to child.
      for (i=UTEXT;i<USTACKTOP;i+=PGSIZE)
  801339:	81 c3 00 10 00 00    	add    $0x1000,%ebx
  80133f:	89 de                	mov    %ebx,%esi
  801341:	81 fb 00 e0 bf ee    	cmp    $0xeebfe000,%ebx
  801347:	0f 85 c9 fe ff ff    	jne    801216 <fork+0xd4>
        if (vpd[VPD(i)]&PTE_P)
          duppage(childId, i);

      // Set child as runnable.
      if ((r = sys_env_set_status(childId, ENV_RUNNABLE)) < 0)
  80134d:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  801354:	00 
  801355:	8b 45 d8             	mov    -0x28(%ebp),%eax
  801358:	89 04 24             	mov    %eax,(%esp)
  80135b:	e8 7c fb ff ff       	call   800edc <sys_env_set_status>
  801360:	85 c0                	test   %eax,%eax
  801362:	79 3d                	jns    8013a1 <fork+0x25f>
        panic("Parent: sys_env_set_status: %e\n", r);
  801364:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801368:	c7 44 24 08 0c 32 80 	movl   $0x80320c,0x8(%esp)
  80136f:	00 
  801370:	c7 44 24 04 8f 00 00 	movl   $0x8f,0x4(%esp)
  801377:	00 
  801378:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  80137f:	e8 30 15 00 00       	call   8028b4 <_panic>
    } else if (childId==0) {
  801384:	83 7d d8 00          	cmpl   $0x0,-0x28(%ebp)
  801388:	75 17                	jne    8013a1 <fork+0x25f>
      env = &envs [ENVX(sys_getenvid())];
  80138a:	e8 fa fc ff ff       	call   801089 <sys_getenvid>
  80138f:	25 ff 03 00 00       	and    $0x3ff,%eax
  801394:	6b c0 7c             	imul   $0x7c,%eax,%eax
  801397:	05 00 00 c0 ee       	add    $0xeec00000,%eax
  80139c:	a3 74 70 80 00       	mov    %eax,0x807074
    }
    return childId;
}
  8013a1:	8b 45 d8             	mov    -0x28(%ebp),%eax
  8013a4:	83 c4 3c             	add    $0x3c,%esp
  8013a7:	5b                   	pop    %ebx
  8013a8:	5e                   	pop    %esi
  8013a9:	5f                   	pop    %edi
  8013aa:	5d                   	pop    %ebp
  8013ab:	c3                   	ret    

008013ac <pgfault>:
// Custom page fault handler - if faulting page is copy-on-write,
// map in our own private writable copy.
//
static void
pgfault(struct UTrapframe *utf)
{
  8013ac:	55                   	push   %ebp
  8013ad:	89 e5                	mov    %esp,%ebp
  8013af:	57                   	push   %edi
  8013b0:	56                   	push   %esi
  8013b1:	53                   	push   %ebx
  8013b2:	83 ec 3c             	sub    $0x3c,%esp
  void *addr    = (void *) utf->utf_fault_va;
  8013b5:	8b 45 08             	mov    0x8(%ebp),%eax
  8013b8:	8b 38                	mov    (%eax),%edi
  uint32_t err  = utf->utf_err;
  8013ba:	8b 50 04             	mov    0x4(%eax),%edx
  8013bd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  int r         = 0;
  int perm      = 0;
  void *align   = (void *)((int)addr&(~0xFFF));
  8013c0:	89 fe                	mov    %edi,%esi
  8013c2:	81 e6 00 f0 ff ff    	and    $0xfffff000,%esi
  envid_t envid = sys_getenvid();
  8013c8:	e8 bc fc ff ff       	call   801089 <sys_getenvid>
  8013cd:	89 c3                	mov    %eax,%ebx
	// copy-on-write page.  If not, panic.
	// Hint:
	//   Use the read-only page table mappings at vpt
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
  8013cf:	89 f2                	mov    %esi,%edx
  8013d1:	89 f0                	mov    %esi,%eax
  8013d3:	c1 e8 16             	shr    $0x16,%eax
  8013d6:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  8013dd:	a8 01                	test   $0x1,%al
  8013df:	74 3e                	je     80141f <pgfault+0x73>
  8013e1:	c1 ea 0c             	shr    $0xc,%edx
  8013e4:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  8013eb:	a8 01                	test   $0x1,%al
  8013ed:	74 30                	je     80141f <pgfault+0x73>
    perm  = vpt[VPN(addr)]&PTE_USER;
  8013ef:	c1 ef 0c             	shr    $0xc,%edi
  8013f2:	8b 3c bd 00 00 40 ef 	mov    -0x10c00000(,%edi,4),%edi
	// page to the old page's address.
	// Hint:
	//   You should make three system calls.
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  8013f9:	81 e7 07 06 00 00    	and    $0x607,%edi
  perm    |= PTE_W;
  8013ff:	83 cf 02             	or     $0x2,%edi
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
  801402:	89 7c 24 08          	mov    %edi,0x8(%esp)
  801406:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80140d:	00 
  80140e:	89 1c 24             	mov    %ebx,(%esp)
  801411:	e8 e0 fb ff ff       	call   800ff6 <sys_page_alloc>
  801416:	85 c0                	test   %eax,%eax
  801418:	74 46                	je     801460 <pgfault+0xb4>
  80141a:	e9 cd 00 00 00       	jmp    8014ec <pgfault+0x140>
	//   (see <inc/memlayout.h>).

  if ((vpd[VPD(align)]&PTE_P) && (vpt[VPN(align)]&PTE_P))
    perm  = vpt[VPN(addr)]&PTE_USER;
  else {
    cprintf("Tryig to acess address: %x eip: %x Err: %x\n", align, utf->utf_eip, err);
  80141f:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801422:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801426:	8b 55 08             	mov    0x8(%ebp),%edx
  801429:	8b 42 28             	mov    0x28(%edx),%eax
  80142c:	89 44 24 08          	mov    %eax,0x8(%esp)
  801430:	89 74 24 04          	mov    %esi,0x4(%esp)
  801434:	c7 04 24 2c 32 80 00 	movl   $0x80322c,(%esp)
  80143b:	e8 89 ed ff ff       	call   8001c9 <cprintf>
    panic("Go to hell :[%x]\n", envid);
  801440:	89 5c 24 0c          	mov    %ebx,0xc(%esp)
  801444:	c7 44 24 08 b7 30 80 	movl   $0x8030b7,0x8(%esp)
  80144b:	00 
  80144c:	c7 44 24 04 24 00 00 	movl   $0x24,0x4(%esp)
  801453:	00 
  801454:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  80145b:	e8 54 14 00 00       	call   8028b4 <_panic>
	//   No need to explicitly delete the old page's mapping.
	// LAB 4: Your code here.
  perm    &= (~PTE_COW);
  perm    |= PTE_W;
  if (!(r=sys_page_alloc(envid, (void *)PFTEMP, perm))) {
    memmove((void *)PFTEMP, align, PGSIZE);
  801460:	c7 44 24 08 00 10 00 	movl   $0x1000,0x8(%esp)
  801467:	00 
  801468:	89 74 24 04          	mov    %esi,0x4(%esp)
  80146c:	c7 04 24 00 f0 7f 00 	movl   $0x7ff000,(%esp)
  801473:	e8 dd f5 ff ff       	call   800a55 <memmove>
    if((r=sys_page_map(envid, (void *)PFTEMP, envid, align, perm)))
  801478:	89 7c 24 10          	mov    %edi,0x10(%esp)
  80147c:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801480:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801484:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  80148b:	00 
  80148c:	89 1c 24             	mov    %ebx,(%esp)
  80148f:	e8 04 fb ff ff       	call   800f98 <sys_page_map>
  801494:	85 c0                	test   %eax,%eax
  801496:	74 20                	je     8014b8 <pgfault+0x10c>
      panic("sys_page_map. Error: 0x%x\n", r);
  801498:	89 44 24 0c          	mov    %eax,0xc(%esp)
  80149c:	c7 44 24 08 c9 30 80 	movl   $0x8030c9,0x8(%esp)
  8014a3:	00 
  8014a4:	c7 44 24 04 34 00 00 	movl   $0x34,0x4(%esp)
  8014ab:	00 
  8014ac:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  8014b3:	e8 fc 13 00 00       	call   8028b4 <_panic>

    if ((r=sys_page_unmap(envid, (void *)PFTEMP)))
  8014b8:	c7 44 24 04 00 f0 7f 	movl   $0x7ff000,0x4(%esp)
  8014bf:	00 
  8014c0:	89 1c 24             	mov    %ebx,(%esp)
  8014c3:	e8 72 fa ff ff       	call   800f3a <sys_page_unmap>
  8014c8:	85 c0                	test   %eax,%eax
  8014ca:	74 40                	je     80150c <pgfault+0x160>
      panic("sys_page_unmap. Error: 0x%x\n", r);
  8014cc:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014d0:	c7 44 24 08 e4 30 80 	movl   $0x8030e4,0x8(%esp)
  8014d7:	00 
  8014d8:	c7 44 24 04 37 00 00 	movl   $0x37,0x4(%esp)
  8014df:	00 
  8014e0:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  8014e7:	e8 c8 13 00 00       	call   8028b4 <_panic>
  } else
    panic("sys_page_alloc. Error: %d\n", r);
  8014ec:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8014f0:	c7 44 24 08 01 31 80 	movl   $0x803101,0x8(%esp)
  8014f7:	00 
  8014f8:	c7 44 24 04 39 00 00 	movl   $0x39,0x4(%esp)
  8014ff:	00 
  801500:	c7 04 24 ac 30 80 00 	movl   $0x8030ac,(%esp)
  801507:	e8 a8 13 00 00       	call   8028b4 <_panic>
}
  80150c:	83 c4 3c             	add    $0x3c,%esp
  80150f:	5b                   	pop    %ebx
  801510:	5e                   	pop    %esi
  801511:	5f                   	pop    %edi
  801512:	5d                   	pop    %ebp
  801513:	c3                   	ret    
	...

00801520 <fd2num>:
// File descriptor manipulators
// --------------------------------------------------------------

int
fd2num(struct Fd *fd)
{
  801520:	55                   	push   %ebp
  801521:	89 e5                	mov    %esp,%ebp
  801523:	8b 45 08             	mov    0x8(%ebp),%eax
  801526:	05 00 00 00 30       	add    $0x30000000,%eax
  80152b:	c1 e8 0c             	shr    $0xc,%eax
	return ((uintptr_t) fd - FDTABLE) / PGSIZE;
}
  80152e:	5d                   	pop    %ebp
  80152f:	c3                   	ret    

00801530 <fd2data>:

char*
fd2data(struct Fd *fd)
{
  801530:	55                   	push   %ebp
  801531:	89 e5                	mov    %esp,%ebp
  801533:	83 ec 04             	sub    $0x4,%esp
	return INDEX2DATA(fd2num(fd));
  801536:	8b 45 08             	mov    0x8(%ebp),%eax
  801539:	89 04 24             	mov    %eax,(%esp)
  80153c:	e8 df ff ff ff       	call   801520 <fd2num>
  801541:	05 20 00 0d 00       	add    $0xd0020,%eax
  801546:	c1 e0 0c             	shl    $0xc,%eax
}
  801549:	c9                   	leave  
  80154a:	c3                   	ret    

0080154b <fd_alloc>:
// Returns 0 on success, < 0 on error.  Errors are:
//	-E_MAX_FD: no more file descriptors
// On error, *fd_store is set to 0.
int
fd_alloc(struct Fd **fd_store)
{
  80154b:	55                   	push   %ebp
  80154c:	89 e5                	mov    %esp,%ebp
  80154e:	57                   	push   %edi
  80154f:	56                   	push   %esi
  801550:	53                   	push   %ebx
  801551:	8b 7d 08             	mov    0x8(%ebp),%edi
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
		fd = INDEX2FD(i);
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
  801554:	a1 00 dd 7b ef       	mov    0xef7bdd00,%eax
  801559:	a8 01                	test   $0x1,%al
  80155b:	74 36                	je     801593 <fd_alloc+0x48>
  80155d:	a1 00 00 74 ef       	mov    0xef740000,%eax
  801562:	a8 01                	test   $0x1,%al
  801564:	74 2d                	je     801593 <fd_alloc+0x48>
  801566:	b8 00 10 00 d0       	mov    $0xd0001000,%eax
  80156b:	b9 00 d0 7b ef       	mov    $0xef7bd000,%ecx
  801570:	be 00 00 40 ef       	mov    $0xef400000,%esi
  801575:	89 c3                	mov    %eax,%ebx
  801577:	89 c2                	mov    %eax,%edx
  801579:	c1 ea 16             	shr    $0x16,%edx
  80157c:	8b 14 91             	mov    (%ecx,%edx,4),%edx
  80157f:	f6 c2 01             	test   $0x1,%dl
  801582:	74 14                	je     801598 <fd_alloc+0x4d>
  801584:	89 c2                	mov    %eax,%edx
  801586:	c1 ea 0c             	shr    $0xc,%edx
  801589:	8b 14 96             	mov    (%esi,%edx,4),%edx
  80158c:	f6 c2 01             	test   $0x1,%dl
  80158f:	75 10                	jne    8015a1 <fd_alloc+0x56>
  801591:	eb 05                	jmp    801598 <fd_alloc+0x4d>
  801593:	bb 00 00 00 d0       	mov    $0xd0000000,%ebx
			*fd_store = fd;
  801598:	89 1f                	mov    %ebx,(%edi)
  80159a:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80159f:	eb 17                	jmp    8015b8 <fd_alloc+0x6d>
  8015a1:	05 00 10 00 00       	add    $0x1000,%eax
fd_alloc(struct Fd **fd_store)
{
	int i;
	struct Fd *fd;

	for (i = 0; i < MAXFD; i++) {
  8015a6:	3d 00 00 02 d0       	cmp    $0xd0020000,%eax
  8015ab:	75 c8                	jne    801575 <fd_alloc+0x2a>
		if ((vpd[PDX(fd)] & PTE_P) == 0 || (vpt[VPN(fd)] & PTE_P) == 0) {
			*fd_store = fd;
			return 0;
		}
	}
	*fd_store = 0;
  8015ad:	c7 07 00 00 00 00    	movl   $0x0,(%edi)
  8015b3:	b8 f6 ff ff ff       	mov    $0xfffffff6,%eax
	return -E_MAX_OPEN;
}
  8015b8:	5b                   	pop    %ebx
  8015b9:	5e                   	pop    %esi
  8015ba:	5f                   	pop    %edi
  8015bb:	5d                   	pop    %ebp
  8015bc:	c3                   	ret    

008015bd <fd_lookup>:
// Returns 0 on success (the page is in range and mapped), < 0 on error.
// Errors are:
//	-E_INVAL: fdnum was either not in range or not mapped.
int
fd_lookup(int fdnum, struct Fd **fd_store)
{
  8015bd:	55                   	push   %ebp
  8015be:	89 e5                	mov    %esp,%ebp
	struct Fd *fd=NULL;

	if (fdnum < 0 || fdnum >= MAXFD) {
  8015c0:	8b 45 08             	mov    0x8(%ebp),%eax
  8015c3:	83 f8 1f             	cmp    $0x1f,%eax
  8015c6:	77 36                	ja     8015fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] bad fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	fd = INDEX2FD(fdnum);
  8015c8:	05 00 00 0d 00       	add    $0xd0000,%eax
  8015cd:	c1 e0 0c             	shl    $0xc,%eax
	if (!(vpd[PDX(fd)] & PTE_P) || !(vpt[VPN(fd)] & PTE_P)) {
  8015d0:	89 c2                	mov    %eax,%edx
  8015d2:	c1 ea 16             	shr    $0x16,%edx
  8015d5:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  8015dc:	f6 c2 01             	test   $0x1,%dl
  8015df:	74 1d                	je     8015fe <fd_lookup+0x41>
  8015e1:	89 c2                	mov    %eax,%edx
  8015e3:	c1 ea 0c             	shr    $0xc,%edx
  8015e6:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  8015ed:	f6 c2 01             	test   $0x1,%dl
  8015f0:	74 0c                	je     8015fe <fd_lookup+0x41>
		if (debug)
			cprintf("[%08x] closed fd %d\n", env->env_id, fd);
		return -E_INVAL;
	}
	*fd_store = fd;
  8015f2:	8b 55 0c             	mov    0xc(%ebp),%edx
  8015f5:	89 02                	mov    %eax,(%edx)
  8015f7:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
  8015fc:	eb 05                	jmp    801603 <fd_lookup+0x46>
  8015fe:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801603:	5d                   	pop    %ebp
  801604:	c3                   	ret    

00801605 <seek>:
	return (*dev->dev_write)(fd, buf, n);
}

int
seek(int fdnum, off_t offset)
{
  801605:	55                   	push   %ebp
  801606:	89 e5                	mov    %esp,%ebp
  801608:	83 ec 18             	sub    $0x18,%esp
	int r;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80160b:	8d 45 fc             	lea    -0x4(%ebp),%eax
  80160e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801612:	8b 45 08             	mov    0x8(%ebp),%eax
  801615:	89 04 24             	mov    %eax,(%esp)
  801618:	e8 a0 ff ff ff       	call   8015bd <fd_lookup>
  80161d:	85 c0                	test   %eax,%eax
  80161f:	78 0e                	js     80162f <seek+0x2a>
		return r;
	fd->fd_offset = offset;
  801621:	8b 45 fc             	mov    -0x4(%ebp),%eax
  801624:	8b 55 0c             	mov    0xc(%ebp),%edx
  801627:	89 50 04             	mov    %edx,0x4(%eax)
  80162a:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  80162f:	c9                   	leave  
  801630:	c3                   	ret    

00801631 <dev_lookup>:
	0
};

int
dev_lookup(int dev_id, struct Dev **dev)
{
  801631:	55                   	push   %ebp
  801632:	89 e5                	mov    %esp,%ebp
  801634:	56                   	push   %esi
  801635:	53                   	push   %ebx
  801636:	83 ec 10             	sub    $0x10,%esp
  801639:	8b 4d 08             	mov    0x8(%ebp),%ecx
  80163c:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
  80163f:	ba 00 00 00 00       	mov    $0x0,%edx
int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
		if (devtab[i]->dev_id == dev_id) {
  801644:	b8 04 70 80 00       	mov    $0x807004,%eax
  801649:	39 0d 04 70 80 00    	cmp    %ecx,0x807004
  80164f:	75 11                	jne    801662 <dev_lookup+0x31>
  801651:	eb 04                	jmp    801657 <dev_lookup+0x26>
  801653:	39 08                	cmp    %ecx,(%eax)
  801655:	75 10                	jne    801667 <dev_lookup+0x36>
			*dev = devtab[i];
  801657:	89 03                	mov    %eax,(%ebx)
  801659:	b8 00 00 00 00       	mov    $0x0,%eax
			return 0;
  80165e:	66 90                	xchg   %ax,%ax
  801660:	eb 36                	jmp    801698 <dev_lookup+0x67>

int
dev_lookup(int dev_id, struct Dev **dev)
{
	int i;
	for (i = 0; devtab[i]; i++)
  801662:	be d4 32 80 00       	mov    $0x8032d4,%esi
  801667:	83 c2 01             	add    $0x1,%edx
  80166a:	8b 04 96             	mov    (%esi,%edx,4),%eax
  80166d:	85 c0                	test   %eax,%eax
  80166f:	75 e2                	jne    801653 <dev_lookup+0x22>
		if (devtab[i]->dev_id == dev_id) {
			*dev = devtab[i];
			return 0;
		}
	cprintf("[%08x] unknown device type %d\n", env->env_id, dev_id);
  801671:	a1 74 70 80 00       	mov    0x807074,%eax
  801676:	8b 40 4c             	mov    0x4c(%eax),%eax
  801679:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  80167d:	89 44 24 04          	mov    %eax,0x4(%esp)
  801681:	c7 04 24 58 32 80 00 	movl   $0x803258,(%esp)
  801688:	e8 3c eb ff ff       	call   8001c9 <cprintf>
	*dev = 0;
  80168d:	c7 03 00 00 00 00    	movl   $0x0,(%ebx)
  801693:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
	return -E_INVAL;
}
  801698:	83 c4 10             	add    $0x10,%esp
  80169b:	5b                   	pop    %ebx
  80169c:	5e                   	pop    %esi
  80169d:	5d                   	pop    %ebp
  80169e:	c3                   	ret    

0080169f <fstat>:
	return (*dev->dev_trunc)(fd, newsize);
}

int
fstat(int fdnum, struct Stat *stat)
{
  80169f:	55                   	push   %ebp
  8016a0:	89 e5                	mov    %esp,%ebp
  8016a2:	53                   	push   %ebx
  8016a3:	83 ec 24             	sub    $0x24,%esp
  8016a6:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016a9:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8016ac:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016b0:	8b 45 08             	mov    0x8(%ebp),%eax
  8016b3:	89 04 24             	mov    %eax,(%esp)
  8016b6:	e8 02 ff ff ff       	call   8015bd <fd_lookup>
  8016bb:	85 c0                	test   %eax,%eax
  8016bd:	78 53                	js     801712 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8016bf:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8016c2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8016c6:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8016c9:	8b 00                	mov    (%eax),%eax
  8016cb:	89 04 24             	mov    %eax,(%esp)
  8016ce:	e8 5e ff ff ff       	call   801631 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8016d3:	85 c0                	test   %eax,%eax
  8016d5:	78 3b                	js     801712 <fstat+0x73>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if (!dev->dev_stat)
  8016d7:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  8016dc:	8b 55 f4             	mov    -0xc(%ebp),%edx
  8016df:	83 7a 14 00          	cmpl   $0x0,0x14(%edx)
  8016e3:	74 2d                	je     801712 <fstat+0x73>
		return -E_NOT_SUPP;
	stat->st_name[0] = 0;
  8016e5:	c6 03 00             	movb   $0x0,(%ebx)
	stat->st_size = 0;
  8016e8:	c7 83 80 00 00 00 00 	movl   $0x0,0x80(%ebx)
  8016ef:	00 00 00 
	stat->st_isdir = 0;
  8016f2:	c7 83 84 00 00 00 00 	movl   $0x0,0x84(%ebx)
  8016f9:	00 00 00 
	stat->st_dev = dev;
  8016fc:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8016ff:	89 83 88 00 00 00    	mov    %eax,0x88(%ebx)
	return (*dev->dev_stat)(fd, stat);
  801705:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801709:	8b 55 f0             	mov    -0x10(%ebp),%edx
  80170c:	89 14 24             	mov    %edx,(%esp)
  80170f:	ff 50 14             	call   *0x14(%eax)
}
  801712:	83 c4 24             	add    $0x24,%esp
  801715:	5b                   	pop    %ebx
  801716:	5d                   	pop    %ebp
  801717:	c3                   	ret    

00801718 <ftruncate>:
	return 0;
}

int
ftruncate(int fdnum, off_t newsize)
{
  801718:	55                   	push   %ebp
  801719:	89 e5                	mov    %esp,%ebp
  80171b:	53                   	push   %ebx
  80171c:	83 ec 24             	sub    $0x24,%esp
  80171f:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801722:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801725:	89 44 24 04          	mov    %eax,0x4(%esp)
  801729:	89 1c 24             	mov    %ebx,(%esp)
  80172c:	e8 8c fe ff ff       	call   8015bd <fd_lookup>
  801731:	85 c0                	test   %eax,%eax
  801733:	78 5f                	js     801794 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801735:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801738:	89 44 24 04          	mov    %eax,0x4(%esp)
  80173c:	8b 45 f0             	mov    -0x10(%ebp),%eax
  80173f:	8b 00                	mov    (%eax),%eax
  801741:	89 04 24             	mov    %eax,(%esp)
  801744:	e8 e8 fe ff ff       	call   801631 <dev_lookup>
ftruncate(int fdnum, off_t newsize)
{
	int r;
	struct Dev *dev;
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
  801749:	85 c0                	test   %eax,%eax
  80174b:	78 47                	js     801794 <ftruncate+0x7c>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  80174d:	8b 55 f0             	mov    -0x10(%ebp),%edx
  801750:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  801754:	75 23                	jne    801779 <ftruncate+0x61>
		cprintf("[%08x] ftruncate %d -- bad mode\n",
			env->env_id, fdnum); 
  801756:	a1 74 70 80 00       	mov    0x807074,%eax
	struct Fd *fd;
	if ((r = fd_lookup(fdnum, &fd)) < 0
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
		cprintf("[%08x] ftruncate %d -- bad mode\n",
  80175b:	8b 40 4c             	mov    0x4c(%eax),%eax
  80175e:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801762:	89 44 24 04          	mov    %eax,0x4(%esp)
  801766:	c7 04 24 78 32 80 00 	movl   $0x803278,(%esp)
  80176d:	e8 57 ea ff ff       	call   8001c9 <cprintf>
  801772:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
			env->env_id, fdnum); 
		return -E_INVAL;
  801777:	eb 1b                	jmp    801794 <ftruncate+0x7c>
	}
	if (!dev->dev_trunc)
  801779:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80177c:	8b 48 18             	mov    0x18(%eax),%ecx
  80177f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801784:	85 c9                	test   %ecx,%ecx
  801786:	74 0c                	je     801794 <ftruncate+0x7c>
		return -E_NOT_SUPP;
	return (*dev->dev_trunc)(fd, newsize);
  801788:	8b 45 0c             	mov    0xc(%ebp),%eax
  80178b:	89 44 24 04          	mov    %eax,0x4(%esp)
  80178f:	89 14 24             	mov    %edx,(%esp)
  801792:	ff d1                	call   *%ecx
}
  801794:	83 c4 24             	add    $0x24,%esp
  801797:	5b                   	pop    %ebx
  801798:	5d                   	pop    %ebp
  801799:	c3                   	ret    

0080179a <write>:
	return tot;
}

ssize_t
write(int fdnum, const void *buf, size_t n)
{
  80179a:	55                   	push   %ebp
  80179b:	89 e5                	mov    %esp,%ebp
  80179d:	53                   	push   %ebx
  80179e:	83 ec 24             	sub    $0x24,%esp
  8017a1:	8b 5d 08             	mov    0x8(%ebp),%ebx
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017a4:	8d 45 f0             	lea    -0x10(%ebp),%eax
  8017a7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017ab:	89 1c 24             	mov    %ebx,(%esp)
  8017ae:	e8 0a fe ff ff       	call   8015bd <fd_lookup>
  8017b3:	85 c0                	test   %eax,%eax
  8017b5:	78 66                	js     80181d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  8017b7:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8017ba:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017be:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8017c1:	8b 00                	mov    (%eax),%eax
  8017c3:	89 04 24             	mov    %eax,(%esp)
  8017c6:	e8 66 fe ff ff       	call   801631 <dev_lookup>
{
	int r;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  8017cb:	85 c0                	test   %eax,%eax
  8017cd:	78 4e                	js     80181d <write+0x83>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_RDONLY) {
  8017cf:	8b 55 f0             	mov    -0x10(%ebp),%edx
  8017d2:	f6 42 08 03          	testb  $0x3,0x8(%edx)
  8017d6:	75 23                	jne    8017fb <write+0x61>
		cprintf("[%08x] write %d -- bad mode\n", env->env_id, fdnum);
  8017d8:	a1 74 70 80 00       	mov    0x807074,%eax
  8017dd:	8b 40 4c             	mov    0x4c(%eax),%eax
  8017e0:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  8017e4:	89 44 24 04          	mov    %eax,0x4(%esp)
  8017e8:	c7 04 24 99 32 80 00 	movl   $0x803299,(%esp)
  8017ef:	e8 d5 e9 ff ff       	call   8001c9 <cprintf>
  8017f4:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  8017f9:	eb 22                	jmp    80181d <write+0x83>
	}
	if (debug)
		cprintf("write %d %p %d via dev %s\n",
			fdnum, buf, n, dev->dev_name);
	if (!dev->dev_write)
  8017fb:	8b 45 f4             	mov    -0xc(%ebp),%eax
  8017fe:	8b 48 0c             	mov    0xc(%eax),%ecx
  801801:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801806:	85 c9                	test   %ecx,%ecx
  801808:	74 13                	je     80181d <write+0x83>
		return -E_NOT_SUPP;
	return (*dev->dev_write)(fd, buf, n);
  80180a:	8b 45 10             	mov    0x10(%ebp),%eax
  80180d:	89 44 24 08          	mov    %eax,0x8(%esp)
  801811:	8b 45 0c             	mov    0xc(%ebp),%eax
  801814:	89 44 24 04          	mov    %eax,0x4(%esp)
  801818:	89 14 24             	mov    %edx,(%esp)
  80181b:	ff d1                	call   *%ecx
}
  80181d:	83 c4 24             	add    $0x24,%esp
  801820:	5b                   	pop    %ebx
  801821:	5d                   	pop    %ebp
  801822:	c3                   	ret    

00801823 <read>:
	return r;
}

ssize_t
read(int fdnum, void *buf, size_t n)
{
  801823:	55                   	push   %ebp
  801824:	89 e5                	mov    %esp,%ebp
  801826:	57                   	push   %edi
  801827:	56                   	push   %esi
  801828:	53                   	push   %ebx
  801829:	83 ec 2c             	sub    $0x2c,%esp
  80182c:	8b 5d 08             	mov    0x8(%ebp),%ebx
  80182f:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  801832:	8d 45 e0             	lea    -0x20(%ebp),%eax
  801835:	89 44 24 04          	mov    %eax,0x4(%esp)
  801839:	89 1c 24             	mov    %ebx,(%esp)
  80183c:	e8 7c fd ff ff       	call   8015bd <fd_lookup>
  801841:	85 c0                	test   %eax,%eax
  801843:	0f 88 b0 00 00 00    	js     8018f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
  801849:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80184c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801850:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801853:	8b 00                	mov    (%eax),%eax
  801855:	89 04 24             	mov    %eax,(%esp)
  801858:	e8 d4 fd ff ff       	call   801631 <dev_lookup>
	int r;
	int m, tot;
	struct Dev *dev;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0
  80185d:	85 c0                	test   %eax,%eax
  80185f:	0f 88 94 00 00 00    	js     8018f9 <read+0xd6>
	    || (r = dev_lookup(fd->fd_dev_id, &dev)) < 0)
		return r;
	if ((fd->fd_omode & O_ACCMODE) == O_WRONLY) {
  801865:	8b 45 e0             	mov    -0x20(%ebp),%eax
  801868:	8b 40 08             	mov    0x8(%eax),%eax
  80186b:	83 e0 03             	and    $0x3,%eax
  80186e:	83 f8 01             	cmp    $0x1,%eax
  801871:	75 23                	jne    801896 <read+0x73>
		cprintf("[%08x] read %d -- bad mode\n", env->env_id, fdnum); 
  801873:	a1 74 70 80 00       	mov    0x807074,%eax
  801878:	8b 40 4c             	mov    0x4c(%eax),%eax
  80187b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80187f:	89 44 24 04          	mov    %eax,0x4(%esp)
  801883:	c7 04 24 b6 32 80 00 	movl   $0x8032b6,(%esp)
  80188a:	e8 3a e9 ff ff       	call   8001c9 <cprintf>
  80188f:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
		return -E_INVAL;
  801894:	eb 63                	jmp    8018f9 <read+0xd6>
	}
	if (!dev->dev_read)
  801896:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  80189b:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80189e:	83 7a 08 00          	cmpl   $0x0,0x8(%edx)
  8018a2:	74 55                	je     8018f9 <read+0xd6>
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8018a4:	ba 00 00 00 00       	mov    $0x0,%edx
  8018a9:	bb 00 00 00 00       	mov    $0x0,%ebx
  8018ae:	b8 00 00 00 00       	mov    $0x0,%eax
  8018b3:	85 f6                	test   %esi,%esi
  8018b5:	74 42                	je     8018f9 <read+0xd6>
    int count=0;
    if ((n-tot)/PGSIZE == 0)
  8018b7:	bf 00 10 00 00       	mov    $0x1000,%edi
  8018bc:	89 f0                	mov    %esi,%eax
  8018be:	29 d0                	sub    %edx,%eax
  8018c0:	89 c1                	mov    %eax,%ecx
  8018c2:	81 e1 ff 0f 00 00    	and    $0xfff,%ecx
  8018c8:	3d 00 10 00 00       	cmp    $0x1000,%eax
  8018cd:	0f 43 cf             	cmovae %edi,%ecx
      count = (n-tot)%PGSIZE;
    else
      count = PGSIZE;

	  m = (*dev->dev_read)(fd, (char *)buf + tot, count);
  8018d0:	89 4c 24 08          	mov    %ecx,0x8(%esp)
  8018d4:	03 55 0c             	add    0xc(%ebp),%edx
  8018d7:	89 54 24 04          	mov    %edx,0x4(%esp)
  8018db:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8018de:	89 04 24             	mov    %eax,(%esp)
  8018e1:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8018e4:	ff 50 08             	call   *0x8(%eax)
		if (m < 0)
  8018e7:	85 c0                	test   %eax,%eax
  8018e9:	78 0e                	js     8018f9 <read+0xd6>
			return m;
		if (m == 0)
  8018eb:	85 c0                	test   %eax,%eax
  8018ed:	74 08                	je     8018f7 <read+0xd4>
		return -E_INVAL;
	}
	if (!dev->dev_read)
		return -E_NOT_SUPP;

  for (tot = 0; tot < n; tot += m) {
  8018ef:	01 c3                	add    %eax,%ebx
  8018f1:	89 da                	mov    %ebx,%edx
  8018f3:	39 f3                	cmp    %esi,%ebx
  8018f5:	72 c5                	jb     8018bc <read+0x99>
  8018f7:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  8018f9:	83 c4 2c             	add    $0x2c,%esp
  8018fc:	5b                   	pop    %ebx
  8018fd:	5e                   	pop    %esi
  8018fe:	5f                   	pop    %edi
  8018ff:	5d                   	pop    %ebp
  801900:	c3                   	ret    

00801901 <readn>:

ssize_t
readn(int fdnum, void *buf, size_t n)
{
  801901:	55                   	push   %ebp
  801902:	89 e5                	mov    %esp,%ebp
  801904:	57                   	push   %edi
  801905:	56                   	push   %esi
  801906:	53                   	push   %ebx
  801907:	83 ec 1c             	sub    $0x1c,%esp
  80190a:	8b 7d 08             	mov    0x8(%ebp),%edi
  80190d:	8b 75 10             	mov    0x10(%ebp),%esi
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801910:	ba 00 00 00 00       	mov    $0x0,%edx
  801915:	bb 00 00 00 00       	mov    $0x0,%ebx
  80191a:	b8 00 00 00 00       	mov    $0x0,%eax
  80191f:	85 f6                	test   %esi,%esi
  801921:	74 29                	je     80194c <readn+0x4b>
		m = read(fdnum, (char*)buf + tot, n - tot);
  801923:	89 f0                	mov    %esi,%eax
  801925:	29 d0                	sub    %edx,%eax
  801927:	89 44 24 08          	mov    %eax,0x8(%esp)
  80192b:	03 55 0c             	add    0xc(%ebp),%edx
  80192e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801932:	89 3c 24             	mov    %edi,(%esp)
  801935:	e8 e9 fe ff ff       	call   801823 <read>
		if (m < 0)
  80193a:	85 c0                	test   %eax,%eax
  80193c:	78 0e                	js     80194c <readn+0x4b>
			return m;
		if (m == 0)
  80193e:	85 c0                	test   %eax,%eax
  801940:	74 08                	je     80194a <readn+0x49>
readn(int fdnum, void *buf, size_t n)
{
	int m, tot;
  struct Fd *fd = INDEX2FD(fdnum);

	for (tot = 0; tot < n; tot += m) {
  801942:	01 c3                	add    %eax,%ebx
  801944:	89 da                	mov    %ebx,%edx
  801946:	39 f3                	cmp    %esi,%ebx
  801948:	72 d9                	jb     801923 <readn+0x22>
  80194a:	89 d8                	mov    %ebx,%eax
			return m;
		if (m == 0)
			break;
	}
	return tot;
}
  80194c:	83 c4 1c             	add    $0x1c,%esp
  80194f:	5b                   	pop    %ebx
  801950:	5e                   	pop    %esi
  801951:	5f                   	pop    %edi
  801952:	5d                   	pop    %ebp
  801953:	c3                   	ret    

00801954 <fd_close>:
// If 'must_exist' is 1, then fd_close returns -E_INVAL when passed a
// closed or nonexistent file descriptor.
// Returns 0 on success, < 0 on error.
int
fd_close(struct Fd *fd, bool must_exist)
{
  801954:	55                   	push   %ebp
  801955:	89 e5                	mov    %esp,%ebp
  801957:	83 ec 28             	sub    $0x28,%esp
  80195a:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  80195d:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801960:	8b 75 08             	mov    0x8(%ebp),%esi
	struct Fd *fd2;
	struct Dev *dev;
	int r;
	if ((r = fd_lookup(fd2num(fd), &fd2)) < 0
  801963:	89 34 24             	mov    %esi,(%esp)
  801966:	e8 b5 fb ff ff       	call   801520 <fd2num>
  80196b:	8d 55 f4             	lea    -0xc(%ebp),%edx
  80196e:	89 54 24 04          	mov    %edx,0x4(%esp)
  801972:	89 04 24             	mov    %eax,(%esp)
  801975:	e8 43 fc ff ff       	call   8015bd <fd_lookup>
  80197a:	89 c3                	mov    %eax,%ebx
  80197c:	85 c0                	test   %eax,%eax
  80197e:	78 05                	js     801985 <fd_close+0x31>
  801980:	3b 75 f4             	cmp    -0xc(%ebp),%esi
  801983:	74 0e                	je     801993 <fd_close+0x3f>
	    || fd != fd2)
		return (must_exist ? r : 0);
  801985:	83 7d 0c 00          	cmpl   $0x0,0xc(%ebp)
  801989:	b8 00 00 00 00       	mov    $0x0,%eax
  80198e:	0f 44 d8             	cmove  %eax,%ebx
  801991:	eb 3d                	jmp    8019d0 <fd_close+0x7c>
	if ((r = dev_lookup(fd->fd_dev_id, &dev)) >= 0) {
  801993:	8d 45 f0             	lea    -0x10(%ebp),%eax
  801996:	89 44 24 04          	mov    %eax,0x4(%esp)
  80199a:	8b 06                	mov    (%esi),%eax
  80199c:	89 04 24             	mov    %eax,(%esp)
  80199f:	e8 8d fc ff ff       	call   801631 <dev_lookup>
  8019a4:	89 c3                	mov    %eax,%ebx
  8019a6:	85 c0                	test   %eax,%eax
  8019a8:	78 16                	js     8019c0 <fd_close+0x6c>
		if (dev->dev_close)
  8019aa:	8b 45 f0             	mov    -0x10(%ebp),%eax
  8019ad:	8b 40 10             	mov    0x10(%eax),%eax
  8019b0:	bb 00 00 00 00       	mov    $0x0,%ebx
  8019b5:	85 c0                	test   %eax,%eax
  8019b7:	74 07                	je     8019c0 <fd_close+0x6c>
			r = (*dev->dev_close)(fd);
  8019b9:	89 34 24             	mov    %esi,(%esp)
  8019bc:	ff d0                	call   *%eax
  8019be:	89 c3                	mov    %eax,%ebx
		else
			r = 0;
	}
	// Make sure fd is unmapped.  Might be a no-op if
	// (*dev->dev_close)(fd) already unmapped it.
	(void) sys_page_unmap(0, fd);
  8019c0:	89 74 24 04          	mov    %esi,0x4(%esp)
  8019c4:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8019cb:	e8 6a f5 ff ff       	call   800f3a <sys_page_unmap>
	return r;
}
  8019d0:	89 d8                	mov    %ebx,%eax
  8019d2:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  8019d5:	8b 75 fc             	mov    -0x4(%ebp),%esi
  8019d8:	89 ec                	mov    %ebp,%esp
  8019da:	5d                   	pop    %ebp
  8019db:	c3                   	ret    

008019dc <close>:
	return -E_INVAL;
}

int
close(int fdnum)
{
  8019dc:	55                   	push   %ebp
  8019dd:	89 e5                	mov    %esp,%ebp
  8019df:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  8019e2:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8019e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8019e9:	8b 45 08             	mov    0x8(%ebp),%eax
  8019ec:	89 04 24             	mov    %eax,(%esp)
  8019ef:	e8 c9 fb ff ff       	call   8015bd <fd_lookup>
  8019f4:	85 c0                	test   %eax,%eax
  8019f6:	78 13                	js     801a0b <close+0x2f>
		return r;
	else
		return fd_close(fd, 1);
  8019f8:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8019ff:	00 
  801a00:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801a03:	89 04 24             	mov    %eax,(%esp)
  801a06:	e8 49 ff ff ff       	call   801954 <fd_close>
}
  801a0b:	c9                   	leave  
  801a0c:	c3                   	ret    

00801a0d <stat>:
	return (*dev->dev_stat)(fd, stat);
}

int
stat(const char *path, struct Stat *stat)
{
  801a0d:	55                   	push   %ebp
  801a0e:	89 e5                	mov    %esp,%ebp
  801a10:	83 ec 18             	sub    $0x18,%esp
  801a13:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801a16:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int fd, r;

	if ((fd = open(path, O_RDONLY)) < 0)
  801a19:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801a20:	00 
  801a21:	8b 45 08             	mov    0x8(%ebp),%eax
  801a24:	89 04 24             	mov    %eax,(%esp)
  801a27:	e8 80 03 00 00       	call   801dac <open>
  801a2c:	89 c3                	mov    %eax,%ebx
  801a2e:	85 c0                	test   %eax,%eax
  801a30:	78 1b                	js     801a4d <stat+0x40>
		return fd;
	r = fstat(fd, stat);
  801a32:	8b 45 0c             	mov    0xc(%ebp),%eax
  801a35:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a39:	89 1c 24             	mov    %ebx,(%esp)
  801a3c:	e8 5e fc ff ff       	call   80169f <fstat>
  801a41:	89 c6                	mov    %eax,%esi
	close(fd);
  801a43:	89 1c 24             	mov    %ebx,(%esp)
  801a46:	e8 91 ff ff ff       	call   8019dc <close>
  801a4b:	89 f3                	mov    %esi,%ebx
	return r;
}
  801a4d:	89 d8                	mov    %ebx,%eax
  801a4f:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801a52:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801a55:	89 ec                	mov    %ebp,%esp
  801a57:	5d                   	pop    %ebp
  801a58:	c3                   	ret    

00801a59 <close_all>:
		return fd_close(fd, 1);
}

void
close_all(void)
{
  801a59:	55                   	push   %ebp
  801a5a:	89 e5                	mov    %esp,%ebp
  801a5c:	53                   	push   %ebx
  801a5d:	83 ec 14             	sub    $0x14,%esp
  801a60:	bb 00 00 00 00       	mov    $0x0,%ebx
	int i;
	for (i = 0; i < MAXFD; i++)
		close(i);
  801a65:	89 1c 24             	mov    %ebx,(%esp)
  801a68:	e8 6f ff ff ff       	call   8019dc <close>

void
close_all(void)
{
	int i;
	for (i = 0; i < MAXFD; i++)
  801a6d:	83 c3 01             	add    $0x1,%ebx
  801a70:	83 fb 20             	cmp    $0x20,%ebx
  801a73:	75 f0                	jne    801a65 <close_all+0xc>
		close(i);
}
  801a75:	83 c4 14             	add    $0x14,%esp
  801a78:	5b                   	pop    %ebx
  801a79:	5d                   	pop    %ebp
  801a7a:	c3                   	ret    

00801a7b <dup>:
// file and the file offset of the other.
// Closes any previously open file descriptor at 'newfdnum'.
// This is implemented using virtual memory tricks (of course!).
int
dup(int oldfdnum, int newfdnum)
{
  801a7b:	55                   	push   %ebp
  801a7c:	89 e5                	mov    %esp,%ebp
  801a7e:	83 ec 58             	sub    $0x58,%esp
  801a81:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  801a84:	89 75 f8             	mov    %esi,-0x8(%ebp)
  801a87:	89 7d fc             	mov    %edi,-0x4(%ebp)
  801a8a:	8b 7d 0c             	mov    0xc(%ebp),%edi
	int r;
	char *ova, *nva;
	pte_t pte;
	struct Fd *oldfd, *newfd;

	if ((r = fd_lookup(oldfdnum, &oldfd)) < 0)
  801a8d:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  801a90:	89 44 24 04          	mov    %eax,0x4(%esp)
  801a94:	8b 45 08             	mov    0x8(%ebp),%eax
  801a97:	89 04 24             	mov    %eax,(%esp)
  801a9a:	e8 1e fb ff ff       	call   8015bd <fd_lookup>
  801a9f:	89 c3                	mov    %eax,%ebx
  801aa1:	85 c0                	test   %eax,%eax
  801aa3:	0f 88 e0 00 00 00    	js     801b89 <dup+0x10e>
		return r;
	close(newfdnum);
  801aa9:	89 3c 24             	mov    %edi,(%esp)
  801aac:	e8 2b ff ff ff       	call   8019dc <close>

	newfd = INDEX2FD(newfdnum);
  801ab1:	8d b7 00 00 0d 00    	lea    0xd0000(%edi),%esi
  801ab7:	c1 e6 0c             	shl    $0xc,%esi
	ova = fd2data(oldfd);
  801aba:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801abd:	89 04 24             	mov    %eax,(%esp)
  801ac0:	e8 6b fa ff ff       	call   801530 <fd2data>
  801ac5:	89 c3                	mov    %eax,%ebx
	nva = fd2data(newfd);
  801ac7:	89 34 24             	mov    %esi,(%esp)
  801aca:	e8 61 fa ff ff       	call   801530 <fd2data>
  801acf:	89 45 d4             	mov    %eax,-0x2c(%ebp)
	if ((vpd[PDX(ova)] & PTE_P) && (vpt[VPN(ova)] & PTE_P))
  801ad2:	89 da                	mov    %ebx,%edx
  801ad4:	89 d8                	mov    %ebx,%eax
  801ad6:	c1 e8 16             	shr    $0x16,%eax
  801ad9:	8b 04 85 00 d0 7b ef 	mov    -0x10843000(,%eax,4),%eax
  801ae0:	a8 01                	test   $0x1,%al
  801ae2:	74 43                	je     801b27 <dup+0xac>
  801ae4:	c1 ea 0c             	shr    $0xc,%edx
  801ae7:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801aee:	a8 01                	test   $0x1,%al
  801af0:	74 35                	je     801b27 <dup+0xac>
		if ((r = sys_page_map(0, ova, 0, nva, (vpt[VPN(ova)]) & PTE_USER)) < 0)
  801af2:	8b 04 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%eax
  801af9:	25 07 0e 00 00       	and    $0xe07,%eax
  801afe:	89 44 24 10          	mov    %eax,0x10(%esp)
  801b02:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801b05:	89 44 24 0c          	mov    %eax,0xc(%esp)
  801b09:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801b10:	00 
  801b11:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801b15:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b1c:	e8 77 f4 ff ff       	call   800f98 <sys_page_map>
  801b21:	89 c3                	mov    %eax,%ebx
  801b23:	85 c0                	test   %eax,%eax
  801b25:	78 3f                	js     801b66 <dup+0xeb>
			goto err;
	if ((r = sys_page_map(0, oldfd, 0, newfd, (vpt[VPN(oldfd)]) & PTE_USER)) < 0)
  801b27:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  801b2a:	89 c2                	mov    %eax,%edx
  801b2c:	c1 ea 0c             	shr    $0xc,%edx
  801b2f:	8b 14 95 00 00 40 ef 	mov    -0x10c00000(,%edx,4),%edx
  801b36:	81 e2 07 0e 00 00    	and    $0xe07,%edx
  801b3c:	89 54 24 10          	mov    %edx,0x10(%esp)
  801b40:	89 74 24 0c          	mov    %esi,0xc(%esp)
  801b44:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801b4b:	00 
  801b4c:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b50:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b57:	e8 3c f4 ff ff       	call   800f98 <sys_page_map>
  801b5c:	89 c3                	mov    %eax,%ebx
  801b5e:	85 c0                	test   %eax,%eax
  801b60:	78 04                	js     801b66 <dup+0xeb>
  801b62:	89 fb                	mov    %edi,%ebx
  801b64:	eb 23                	jmp    801b89 <dup+0x10e>
		goto err;

	return newfdnum;
err:
	sys_page_unmap(0, newfd);
  801b66:	89 74 24 04          	mov    %esi,0x4(%esp)
  801b6a:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b71:	e8 c4 f3 ff ff       	call   800f3a <sys_page_unmap>
	sys_page_unmap(0, nva);
  801b76:	8b 45 d4             	mov    -0x2c(%ebp),%eax
  801b79:	89 44 24 04          	mov    %eax,0x4(%esp)
  801b7d:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801b84:	e8 b1 f3 ff ff       	call   800f3a <sys_page_unmap>
	return r;
}
  801b89:	89 d8                	mov    %ebx,%eax
  801b8b:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  801b8e:	8b 75 f8             	mov    -0x8(%ebp),%esi
  801b91:	8b 7d fc             	mov    -0x4(%ebp),%edi
  801b94:	89 ec                	mov    %ebp,%esp
  801b96:	5d                   	pop    %ebp
  801b97:	c3                   	ret    

00801b98 <fsipc>:
// type: request code, passed as the simple integer IPC value.
// dstva: virtual address at which to receive reply page, 0 if none.
// Returns result from the file server.
static int
fsipc(unsigned type, void *dstva)
{
  801b98:	55                   	push   %ebp
  801b99:	89 e5                	mov    %esp,%ebp
  801b9b:	53                   	push   %ebx
  801b9c:	83 ec 14             	sub    $0x14,%esp
  801b9f:	89 d3                	mov    %edx,%ebx
	if (debug)
		cprintf("[%08x] fsipc %d %08x\n", env->env_id, type, *(uint32_t *)&fsipcbuf);

	ipc_send(envs[1].env_id, type, &fsipcbuf, PTE_P | PTE_W | PTE_U);
  801ba1:	8b 15 c8 00 c0 ee    	mov    0xeec000c8,%edx
  801ba7:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  801bae:	00 
  801baf:	c7 44 24 08 00 40 80 	movl   $0x804000,0x8(%esp)
  801bb6:	00 
  801bb7:	89 44 24 04          	mov    %eax,0x4(%esp)
  801bbb:	89 14 24             	mov    %edx,(%esp)
  801bbe:	e8 ed 0d 00 00       	call   8029b0 <ipc_send>
	return ipc_recv(NULL, dstva, NULL);
  801bc3:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  801bca:	00 
  801bcb:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801bcf:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801bd6:	e8 47 0e 00 00       	call   802a22 <ipc_recv>
}
  801bdb:	83 c4 14             	add    $0x14,%esp
  801bde:	5b                   	pop    %ebx
  801bdf:	5d                   	pop    %ebp
  801be0:	c3                   	ret    

00801be1 <devfile_trunc>:
}

// Truncate or extend an open file to 'size' bytes
static int
devfile_trunc(struct Fd *fd, off_t newsize)
{
  801be1:	55                   	push   %ebp
  801be2:	89 e5                	mov    %esp,%ebp
  801be4:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.set_size.req_fileid = fd->fd_file.id;
  801be7:	8b 45 08             	mov    0x8(%ebp),%eax
  801bea:	8b 40 0c             	mov    0xc(%eax),%eax
  801bed:	a3 00 40 80 00       	mov    %eax,0x804000
	fsipcbuf.set_size.req_size = newsize;
  801bf2:	8b 45 0c             	mov    0xc(%ebp),%eax
  801bf5:	a3 04 40 80 00       	mov    %eax,0x804004
	return fsipc(FSREQ_SET_SIZE, NULL);
  801bfa:	ba 00 00 00 00       	mov    $0x0,%edx
  801bff:	b8 02 00 00 00       	mov    $0x2,%eax
  801c04:	e8 8f ff ff ff       	call   801b98 <fsipc>
}
  801c09:	c9                   	leave  
  801c0a:	c3                   	ret    

00801c0b <devfile_flush>:
// open, unmapping it is enough to free up server-side resources.
// Other than that, we just have to make sure our changes are flushed
// to disk.
static int
devfile_flush(struct Fd *fd)
{
  801c0b:	55                   	push   %ebp
  801c0c:	89 e5                	mov    %esp,%ebp
  801c0e:	83 ec 08             	sub    $0x8,%esp
	fsipcbuf.flush.req_fileid = fd->fd_file.id;
  801c11:	8b 45 08             	mov    0x8(%ebp),%eax
  801c14:	8b 40 0c             	mov    0xc(%eax),%eax
  801c17:	a3 00 40 80 00       	mov    %eax,0x804000
	return fsipc(FSREQ_FLUSH, NULL);
  801c1c:	ba 00 00 00 00       	mov    $0x0,%edx
  801c21:	b8 06 00 00 00       	mov    $0x6,%eax
  801c26:	e8 6d ff ff ff       	call   801b98 <fsipc>
}
  801c2b:	c9                   	leave  
  801c2c:	c3                   	ret    

00801c2d <sync>:
}

// Synchronize disk with buffer cache
int
sync(void)
{
  801c2d:	55                   	push   %ebp
  801c2e:	89 e5                	mov    %esp,%ebp
  801c30:	83 ec 08             	sub    $0x8,%esp
	// Ask the file server to update the disk
	// by writing any dirty blocks in the buffer cache.

	return fsipc(FSREQ_SYNC, NULL);
  801c33:	ba 00 00 00 00       	mov    $0x0,%edx
  801c38:	b8 08 00 00 00       	mov    $0x8,%eax
  801c3d:	e8 56 ff ff ff       	call   801b98 <fsipc>
}
  801c42:	c9                   	leave  
  801c43:	c3                   	ret    

00801c44 <devfile_stat>:
    return n;
}

static int
devfile_stat(struct Fd *fd, struct Stat *st)
{
  801c44:	55                   	push   %ebp
  801c45:	89 e5                	mov    %esp,%ebp
  801c47:	53                   	push   %ebx
  801c48:	83 ec 14             	sub    $0x14,%esp
  801c4b:	8b 5d 0c             	mov    0xc(%ebp),%ebx
	int r;

	fsipcbuf.stat.req_fileid = fd->fd_file.id;
  801c4e:	8b 45 08             	mov    0x8(%ebp),%eax
  801c51:	8b 40 0c             	mov    0xc(%eax),%eax
  801c54:	a3 00 40 80 00       	mov    %eax,0x804000
	if ((r = fsipc(FSREQ_STAT, NULL)) < 0)
  801c59:	ba 00 00 00 00       	mov    $0x0,%edx
  801c5e:	b8 05 00 00 00       	mov    $0x5,%eax
  801c63:	e8 30 ff ff ff       	call   801b98 <fsipc>
  801c68:	85 c0                	test   %eax,%eax
  801c6a:	78 2b                	js     801c97 <devfile_stat+0x53>
		return r;
	strcpy(st->st_name, fsipcbuf.statRet.ret_name);
  801c6c:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801c73:	00 
  801c74:	89 1c 24             	mov    %ebx,(%esp)
  801c77:	e8 1e ec ff ff       	call   80089a <strcpy>
	st->st_size = fsipcbuf.statRet.ret_size;
  801c7c:	a1 80 40 80 00       	mov    0x804080,%eax
  801c81:	89 83 80 00 00 00    	mov    %eax,0x80(%ebx)
	st->st_isdir = fsipcbuf.statRet.ret_isdir;
  801c87:	a1 84 40 80 00       	mov    0x804084,%eax
  801c8c:	89 83 84 00 00 00    	mov    %eax,0x84(%ebx)
  801c92:	b8 00 00 00 00       	mov    $0x0,%eax
	return 0;
}
  801c97:	83 c4 14             	add    $0x14,%esp
  801c9a:	5b                   	pop    %ebx
  801c9b:	5d                   	pop    %ebp
  801c9c:	c3                   	ret    

00801c9d <devfile_write>:
// Returns:
//	 The number of bytes successfully written.
//	 < 0 on error.
static ssize_t
devfile_write(struct Fd *fd, const void *buf, size_t n)
{
  801c9d:	55                   	push   %ebp
  801c9e:	89 e5                	mov    %esp,%ebp
  801ca0:	53                   	push   %ebx
  801ca1:	83 ec 14             	sub    $0x14,%esp
  801ca4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ca7:	8b 55 0c             	mov    0xc(%ebp),%edx
  801caa:	8b 5d 10             	mov    0x10(%ebp),%ebx
	// careful: fsipcbuf.write.req_buf is only so large, but
	// remember that write is always allowed to write *fewer*
	// bytes than requested.
	// LAB 5: Your code here
    int r;
    if (!fd || !buf || (n>(PGSIZE-sizeof(size_t)-sizeof(int))))
  801cad:	85 c0                	test   %eax,%eax
  801caf:	74 44                	je     801cf5 <devfile_write+0x58>
  801cb1:	85 d2                	test   %edx,%edx
  801cb3:	74 40                	je     801cf5 <devfile_write+0x58>
  801cb5:	81 fb f8 0f 00 00    	cmp    $0xff8,%ebx
  801cbb:	77 38                	ja     801cf5 <devfile_write+0x58>
        return -E_INVAL;

    fsipcbuf.write.req_fileid   = fd->fd_file.id;
  801cbd:	8b 40 0c             	mov    0xc(%eax),%eax
  801cc0:	a3 00 40 80 00       	mov    %eax,0x804000
    fsipcbuf.write.req_n        = n;
  801cc5:	89 1d 04 40 80 00    	mov    %ebx,0x804004
    memmove(fsipcbuf.write.req_buf, buf, n);
  801ccb:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  801ccf:	89 54 24 04          	mov    %edx,0x4(%esp)
  801cd3:	c7 04 24 08 40 80 00 	movl   $0x804008,(%esp)
  801cda:	e8 76 ed ff ff       	call   800a55 <memmove>
    if ((r=fsipc(FSREQ_WRITE, NULL))<0)
  801cdf:	ba 00 00 00 00       	mov    $0x0,%edx
  801ce4:	b8 04 00 00 00       	mov    $0x4,%eax
  801ce9:	e8 aa fe ff ff       	call   801b98 <fsipc>
        return r;
    return n;
  801cee:	85 c0                	test   %eax,%eax
  801cf0:	0f 49 c3             	cmovns %ebx,%eax
  801cf3:	eb 05                	jmp    801cfa <devfile_write+0x5d>
  801cf5:	b8 fd ff ff ff       	mov    $0xfffffffd,%eax
}
  801cfa:	83 c4 14             	add    $0x14,%esp
  801cfd:	5b                   	pop    %ebx
  801cfe:	5d                   	pop    %ebp
  801cff:	c3                   	ret    

00801d00 <devfile_read>:
// Returns:
// 	The number of bytes successfully read.
// 	< 0 on error.
static ssize_t
devfile_read(struct Fd *fd, void *buf, size_t n)
{
  801d00:	55                   	push   %ebp
  801d01:	89 e5                	mov    %esp,%ebp
  801d03:	83 ec 18             	sub    $0x18,%esp
  801d06:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801d09:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801d0c:	8b 45 08             	mov    0x8(%ebp),%eax
  801d0f:	8b 75 0c             	mov    0xc(%ebp),%esi
	// filling fsipcbuf.read with the request arguments.  The
	// bytes read will be written back to fsipcbuf by the file
	// system server.
	// LAB 5: Your code here
  int r;
  if (!fd || !buf)
  801d12:	85 c0                	test   %eax,%eax
  801d14:	74 04                	je     801d1a <devfile_read+0x1a>
  801d16:	85 f6                	test   %esi,%esi
  801d18:	75 07                	jne    801d21 <devfile_read+0x21>
  801d1a:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801d1f:	eb 39                	jmp    801d5a <devfile_read+0x5a>
    return -E_INVAL;

  fsipcbuf.read.req_fileid    = fd->fd_file.id;
  801d21:	8b 40 0c             	mov    0xc(%eax),%eax
  801d24:	a3 00 40 80 00       	mov    %eax,0x804000
  fsipcbuf.read.req_n         = n;
  801d29:	8b 45 10             	mov    0x10(%ebp),%eax
  801d2c:	a3 04 40 80 00       	mov    %eax,0x804004
  if ((r=fsipc(FSREQ_READ, NULL))<0)
  801d31:	ba 00 00 00 00       	mov    $0x0,%edx
  801d36:	b8 03 00 00 00       	mov    $0x3,%eax
  801d3b:	e8 58 fe ff ff       	call   801b98 <fsipc>
  801d40:	89 c3                	mov    %eax,%ebx
  801d42:	85 c0                	test   %eax,%eax
  801d44:	78 14                	js     801d5a <devfile_read+0x5a>
    return r;

  memmove(buf, fsipcbuf.readRet.ret_buf, r);
  801d46:	89 44 24 08          	mov    %eax,0x8(%esp)
  801d4a:	c7 44 24 04 00 40 80 	movl   $0x804000,0x4(%esp)
  801d51:	00 
  801d52:	89 34 24             	mov    %esi,(%esp)
  801d55:	e8 fb ec ff ff       	call   800a55 <memmove>
  return r;
}
  801d5a:	89 d8                	mov    %ebx,%eax
  801d5c:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801d5f:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801d62:	89 ec                	mov    %ebp,%esp
  801d64:	5d                   	pop    %ebp
  801d65:	c3                   	ret    

00801d66 <remove>:
}

// Delete a file
int
remove(const char *path)
{
  801d66:	55                   	push   %ebp
  801d67:	89 e5                	mov    %esp,%ebp
  801d69:	53                   	push   %ebx
  801d6a:	83 ec 14             	sub    $0x14,%esp
  801d6d:	8b 5d 08             	mov    0x8(%ebp),%ebx
	if (strlen(path) >= MAXPATHLEN)
  801d70:	89 1c 24             	mov    %ebx,(%esp)
  801d73:	e8 d8 ea ff ff       	call   800850 <strlen>
  801d78:	89 c2                	mov    %eax,%edx
  801d7a:	b8 f4 ff ff ff       	mov    $0xfffffff4,%eax
  801d7f:	81 fa ff 03 00 00    	cmp    $0x3ff,%edx
  801d85:	7f 1f                	jg     801da6 <remove+0x40>
		return -E_BAD_PATH;
	strcpy(fsipcbuf.remove.req_path, path);
  801d87:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  801d8b:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801d92:	e8 03 eb ff ff       	call   80089a <strcpy>
	return fsipc(FSREQ_REMOVE, NULL);
  801d97:	ba 00 00 00 00       	mov    $0x0,%edx
  801d9c:	b8 07 00 00 00       	mov    $0x7,%eax
  801da1:	e8 f2 fd ff ff       	call   801b98 <fsipc>
}
  801da6:	83 c4 14             	add    $0x14,%esp
  801da9:	5b                   	pop    %ebx
  801daa:	5d                   	pop    %ebp
  801dab:	c3                   	ret    

00801dac <open>:
// 	The file descriptor index on success
// 	-E_BAD_PATH if the path is too long (>= MAXPATHLEN)
// 	< 0 for other errors.
int
open(const char *path, int mode)
{
  801dac:	55                   	push   %ebp
  801dad:	89 e5                	mov    %esp,%ebp
  801daf:	83 ec 28             	sub    $0x28,%esp
  801db2:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  801db5:	89 75 fc             	mov    %esi,-0x4(%ebp)
  801db8:	8b 75 08             	mov    0x8(%ebp),%esi
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  int r   = 0;

  if (!path)
  801dbb:	bb fd ff ff ff       	mov    $0xfffffffd,%ebx
  801dc0:	85 f6                	test   %esi,%esi
  801dc2:	74 65                	je     801e29 <open+0x7d>
	// (fd_alloc does not allocate a page, it just returns an
	// unused fd address.  Do you need to allocate a page?)
	//
	// Return the file descriptor index.
	// If any step after fd_alloc fails, use fd_close to free the
  struct Fd *f    = NULL;
  801dc4:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
  int r   = 0;

  if (!path)
    return -E_INVAL;
  if((r=fd_alloc(&f))<0)
  801dcb:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801dce:	89 04 24             	mov    %eax,(%esp)
  801dd1:	e8 75 f7 ff ff       	call   80154b <fd_alloc>
  801dd6:	89 c3                	mov    %eax,%ebx
  801dd8:	85 c0                	test   %eax,%eax
  801dda:	78 4d                	js     801e29 <open+0x7d>
    return r;

	strcpy(fsipcbuf.open.req_path, path);
  801ddc:	89 74 24 04          	mov    %esi,0x4(%esp)
  801de0:	c7 04 24 00 40 80 00 	movl   $0x804000,(%esp)
  801de7:	e8 ae ea ff ff       	call   80089a <strcpy>
	fsipcbuf.open.req_omode = mode;
  801dec:	8b 45 0c             	mov    0xc(%ebp),%eax
  801def:	a3 00 44 80 00       	mov    %eax,0x804400

  if ((r=fsipc(FSREQ_OPEN, f))<0) {
  801df4:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801df7:	b8 01 00 00 00       	mov    $0x1,%eax
  801dfc:	e8 97 fd ff ff       	call   801b98 <fsipc>
  801e01:	89 c3                	mov    %eax,%ebx
  801e03:	85 c0                	test   %eax,%eax
  801e05:	79 15                	jns    801e1c <open+0x70>
    fd_close(f, 0);
  801e07:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  801e0e:	00 
  801e0f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801e12:	89 04 24             	mov    %eax,(%esp)
  801e15:	e8 3a fb ff ff       	call   801954 <fd_close>
    return r;
  801e1a:	eb 0d                	jmp    801e29 <open+0x7d>
  }
  return fd2num(f);
  801e1c:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801e1f:	89 04 24             	mov    %eax,(%esp)
  801e22:	e8 f9 f6 ff ff       	call   801520 <fd2num>
  801e27:	89 c3                	mov    %eax,%ebx
}
  801e29:	89 d8                	mov    %ebx,%eax
  801e2b:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  801e2e:	8b 75 fc             	mov    -0x4(%ebp),%esi
  801e31:	89 ec                	mov    %ebp,%esp
  801e33:	5d                   	pop    %ebp
  801e34:	c3                   	ret    
	...

00801e40 <devsock_stat>:
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
}

static int
devsock_stat(struct Fd *fd, struct Stat *stat)
{
  801e40:	55                   	push   %ebp
  801e41:	89 e5                	mov    %esp,%ebp
  801e43:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<sock>");
  801e46:	c7 44 24 04 e8 32 80 	movl   $0x8032e8,0x4(%esp)
  801e4d:	00 
  801e4e:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e51:	89 04 24             	mov    %eax,(%esp)
  801e54:	e8 41 ea ff ff       	call   80089a <strcpy>
	return 0;
}
  801e59:	b8 00 00 00 00       	mov    $0x0,%eax
  801e5e:	c9                   	leave  
  801e5f:	c3                   	ret    

00801e60 <devsock_close>:
	return nsipc_shutdown(r, how);
}

static int
devsock_close(struct Fd *fd)
{
  801e60:	55                   	push   %ebp
  801e61:	89 e5                	mov    %esp,%ebp
  801e63:	83 ec 18             	sub    $0x18,%esp
	return nsipc_close(fd->fd_sock.sockid);
  801e66:	8b 45 08             	mov    0x8(%ebp),%eax
  801e69:	8b 40 0c             	mov    0xc(%eax),%eax
  801e6c:	89 04 24             	mov    %eax,(%esp)
  801e6f:	e8 9d 02 00 00       	call   802111 <nsipc_close>
}
  801e74:	c9                   	leave  
  801e75:	c3                   	ret    

00801e76 <devsock_write>:
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
}

static ssize_t
devsock_write(struct Fd *fd, const void *buf, size_t n)
{
  801e76:	55                   	push   %ebp
  801e77:	89 e5                	mov    %esp,%ebp
  801e79:	83 ec 18             	sub    $0x18,%esp
	return nsipc_send(fd->fd_sock.sockid, buf, n, 0);
  801e7c:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801e83:	00 
  801e84:	8b 45 10             	mov    0x10(%ebp),%eax
  801e87:	89 44 24 08          	mov    %eax,0x8(%esp)
  801e8b:	8b 45 0c             	mov    0xc(%ebp),%eax
  801e8e:	89 44 24 04          	mov    %eax,0x4(%esp)
  801e92:	8b 45 08             	mov    0x8(%ebp),%eax
  801e95:	8b 40 0c             	mov    0xc(%eax),%eax
  801e98:	89 04 24             	mov    %eax,(%esp)
  801e9b:	e8 ad 02 00 00       	call   80214d <nsipc_send>
}
  801ea0:	c9                   	leave  
  801ea1:	c3                   	ret    

00801ea2 <devsock_read>:
	return nsipc_listen(r, backlog);
}

static ssize_t
devsock_read(struct Fd *fd, void *buf, size_t n)
{
  801ea2:	55                   	push   %ebp
  801ea3:	89 e5                	mov    %esp,%ebp
  801ea5:	83 ec 18             	sub    $0x18,%esp
	return nsipc_recv(fd->fd_sock.sockid, buf, n, 0);
  801ea8:	c7 44 24 0c 00 00 00 	movl   $0x0,0xc(%esp)
  801eaf:	00 
  801eb0:	8b 45 10             	mov    0x10(%ebp),%eax
  801eb3:	89 44 24 08          	mov    %eax,0x8(%esp)
  801eb7:	8b 45 0c             	mov    0xc(%ebp),%eax
  801eba:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ebe:	8b 45 08             	mov    0x8(%ebp),%eax
  801ec1:	8b 40 0c             	mov    0xc(%eax),%eax
  801ec4:	89 04 24             	mov    %eax,(%esp)
  801ec7:	e8 f4 02 00 00       	call   8021c0 <nsipc_recv>
}
  801ecc:	c9                   	leave  
  801ecd:	c3                   	ret    

00801ece <alloc_sockfd>:
	return sfd->fd_sock.sockid;
}

static int
alloc_sockfd(int sockid)
{
  801ece:	55                   	push   %ebp
  801ecf:	89 e5                	mov    %esp,%ebp
  801ed1:	56                   	push   %esi
  801ed2:	53                   	push   %ebx
  801ed3:	83 ec 20             	sub    $0x20,%esp
  801ed6:	89 c6                	mov    %eax,%esi
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801ed8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  801edb:	89 04 24             	mov    %eax,(%esp)
  801ede:	e8 68 f6 ff ff       	call   80154b <fd_alloc>
  801ee3:	89 c3                	mov    %eax,%ebx
  801ee5:	85 c0                	test   %eax,%eax
  801ee7:	78 21                	js     801f0a <alloc_sockfd+0x3c>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
  801ee9:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  801ef0:	00 
  801ef1:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801ef4:	89 44 24 04          	mov    %eax,0x4(%esp)
  801ef8:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  801eff:	e8 f2 f0 ff ff       	call   800ff6 <sys_page_alloc>
  801f04:	89 c3                	mov    %eax,%ebx
alloc_sockfd(int sockid)
{
	struct Fd *sfd;
	int r;

	if ((r = fd_alloc(&sfd)) < 0
  801f06:	85 c0                	test   %eax,%eax
  801f08:	79 0a                	jns    801f14 <alloc_sockfd+0x46>
	    || (r = sys_page_alloc(0, sfd, PTE_P|PTE_W|PTE_U)) < 0) {
		nsipc_close(sockid);
  801f0a:	89 34 24             	mov    %esi,(%esp)
  801f0d:	e8 ff 01 00 00       	call   802111 <nsipc_close>
		return r;
  801f12:	eb 28                	jmp    801f3c <alloc_sockfd+0x6e>
	}

	sfd->fd_dev_id = devsock.dev_id;
  801f14:	8b 15 20 70 80 00    	mov    0x807020,%edx
  801f1a:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f1d:	89 10                	mov    %edx,(%eax)
	sfd->fd_omode = O_RDWR;
  801f1f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f22:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	sfd->fd_sock.sockid = sockid;
  801f29:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f2c:	89 70 0c             	mov    %esi,0xc(%eax)
	return fd2num(sfd);
  801f2f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  801f32:	89 04 24             	mov    %eax,(%esp)
  801f35:	e8 e6 f5 ff ff       	call   801520 <fd2num>
  801f3a:	89 c3                	mov    %eax,%ebx
}
  801f3c:	89 d8                	mov    %ebx,%eax
  801f3e:	83 c4 20             	add    $0x20,%esp
  801f41:	5b                   	pop    %ebx
  801f42:	5e                   	pop    %esi
  801f43:	5d                   	pop    %ebp
  801f44:	c3                   	ret    

00801f45 <socket>:
	return 0;
}

int
socket(int domain, int type, int protocol)
{
  801f45:	55                   	push   %ebp
  801f46:	89 e5                	mov    %esp,%ebp
  801f48:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = nsipc_socket(domain, type, protocol)) < 0)
  801f4b:	8b 45 10             	mov    0x10(%ebp),%eax
  801f4e:	89 44 24 08          	mov    %eax,0x8(%esp)
  801f52:	8b 45 0c             	mov    0xc(%ebp),%eax
  801f55:	89 44 24 04          	mov    %eax,0x4(%esp)
  801f59:	8b 45 08             	mov    0x8(%ebp),%eax
  801f5c:	89 04 24             	mov    %eax,(%esp)
  801f5f:	e8 61 01 00 00       	call   8020c5 <nsipc_socket>
  801f64:	85 c0                	test   %eax,%eax
  801f66:	78 05                	js     801f6d <socket+0x28>
		return r;
	return alloc_sockfd(r);
  801f68:	e8 61 ff ff ff       	call   801ece <alloc_sockfd>
}
  801f6d:	c9                   	leave  
  801f6e:	66 90                	xchg   %ax,%ax
  801f70:	c3                   	ret    

00801f71 <fd2sockid>:
	.dev_stat =	devsock_stat,
};

static int
fd2sockid(int fd)
{
  801f71:	55                   	push   %ebp
  801f72:	89 e5                	mov    %esp,%ebp
  801f74:	83 ec 28             	sub    $0x28,%esp
	struct Fd *sfd;
	int r;

	if ((r = fd_lookup(fd, &sfd)) < 0)
  801f77:	8d 55 f4             	lea    -0xc(%ebp),%edx
  801f7a:	89 54 24 04          	mov    %edx,0x4(%esp)
  801f7e:	89 04 24             	mov    %eax,(%esp)
  801f81:	e8 37 f6 ff ff       	call   8015bd <fd_lookup>
  801f86:	85 c0                	test   %eax,%eax
  801f88:	78 15                	js     801f9f <fd2sockid+0x2e>
		return r;
	if (sfd->fd_dev_id != devsock.dev_id)
  801f8a:	8b 55 f4             	mov    -0xc(%ebp),%edx
  801f8d:	8b 0a                	mov    (%edx),%ecx
  801f8f:	b8 f1 ff ff ff       	mov    $0xfffffff1,%eax
  801f94:	3b 0d 20 70 80 00    	cmp    0x807020,%ecx
  801f9a:	75 03                	jne    801f9f <fd2sockid+0x2e>
		return -E_NOT_SUPP;
	return sfd->fd_sock.sockid;
  801f9c:	8b 42 0c             	mov    0xc(%edx),%eax
}
  801f9f:	c9                   	leave  
  801fa0:	c3                   	ret    

00801fa1 <listen>:
	return nsipc_connect(r, name, namelen);
}

int
listen(int s, int backlog)
{
  801fa1:	55                   	push   %ebp
  801fa2:	89 e5                	mov    %esp,%ebp
  801fa4:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801fa7:	8b 45 08             	mov    0x8(%ebp),%eax
  801faa:	e8 c2 ff ff ff       	call   801f71 <fd2sockid>
  801faf:	85 c0                	test   %eax,%eax
  801fb1:	78 0f                	js     801fc2 <listen+0x21>
		return r;
	return nsipc_listen(r, backlog);
  801fb3:	8b 55 0c             	mov    0xc(%ebp),%edx
  801fb6:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fba:	89 04 24             	mov    %eax,(%esp)
  801fbd:	e8 2d 01 00 00       	call   8020ef <nsipc_listen>
}
  801fc2:	c9                   	leave  
  801fc3:	c3                   	ret    

00801fc4 <connect>:
	return nsipc_close(fd->fd_sock.sockid);
}

int
connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  801fc4:	55                   	push   %ebp
  801fc5:	89 e5                	mov    %esp,%ebp
  801fc7:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801fca:	8b 45 08             	mov    0x8(%ebp),%eax
  801fcd:	e8 9f ff ff ff       	call   801f71 <fd2sockid>
  801fd2:	85 c0                	test   %eax,%eax
  801fd4:	78 16                	js     801fec <connect+0x28>
		return r;
	return nsipc_connect(r, name, namelen);
  801fd6:	8b 55 10             	mov    0x10(%ebp),%edx
  801fd9:	89 54 24 08          	mov    %edx,0x8(%esp)
  801fdd:	8b 55 0c             	mov    0xc(%ebp),%edx
  801fe0:	89 54 24 04          	mov    %edx,0x4(%esp)
  801fe4:	89 04 24             	mov    %eax,(%esp)
  801fe7:	e8 54 02 00 00       	call   802240 <nsipc_connect>
}
  801fec:	c9                   	leave  
  801fed:	c3                   	ret    

00801fee <shutdown>:
	return nsipc_bind(r, name, namelen);
}

int
shutdown(int s, int how)
{
  801fee:	55                   	push   %ebp
  801fef:	89 e5                	mov    %esp,%ebp
  801ff1:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  801ff4:	8b 45 08             	mov    0x8(%ebp),%eax
  801ff7:	e8 75 ff ff ff       	call   801f71 <fd2sockid>
  801ffc:	85 c0                	test   %eax,%eax
  801ffe:	78 0f                	js     80200f <shutdown+0x21>
		return r;
	return nsipc_shutdown(r, how);
  802000:	8b 55 0c             	mov    0xc(%ebp),%edx
  802003:	89 54 24 04          	mov    %edx,0x4(%esp)
  802007:	89 04 24             	mov    %eax,(%esp)
  80200a:	e8 1c 01 00 00       	call   80212b <nsipc_shutdown>
}
  80200f:	c9                   	leave  
  802010:	c3                   	ret    

00802011 <bind>:
	return alloc_sockfd(r);
}

int
bind(int s, struct sockaddr *name, socklen_t namelen)
{
  802011:	55                   	push   %ebp
  802012:	89 e5                	mov    %esp,%ebp
  802014:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802017:	8b 45 08             	mov    0x8(%ebp),%eax
  80201a:	e8 52 ff ff ff       	call   801f71 <fd2sockid>
  80201f:	85 c0                	test   %eax,%eax
  802021:	78 16                	js     802039 <bind+0x28>
		return r;
	return nsipc_bind(r, name, namelen);
  802023:	8b 55 10             	mov    0x10(%ebp),%edx
  802026:	89 54 24 08          	mov    %edx,0x8(%esp)
  80202a:	8b 55 0c             	mov    0xc(%ebp),%edx
  80202d:	89 54 24 04          	mov    %edx,0x4(%esp)
  802031:	89 04 24             	mov    %eax,(%esp)
  802034:	e8 46 02 00 00       	call   80227f <nsipc_bind>
}
  802039:	c9                   	leave  
  80203a:	c3                   	ret    

0080203b <accept>:
	return fd2num(sfd);
}

int
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  80203b:	55                   	push   %ebp
  80203c:	89 e5                	mov    %esp,%ebp
  80203e:	83 ec 18             	sub    $0x18,%esp
	int r;
	if ((r = fd2sockid(s)) < 0)
  802041:	8b 45 08             	mov    0x8(%ebp),%eax
  802044:	e8 28 ff ff ff       	call   801f71 <fd2sockid>
  802049:	85 c0                	test   %eax,%eax
  80204b:	78 1f                	js     80206c <accept+0x31>
		return r;
	if ((r = nsipc_accept(r, addr, addrlen)) < 0)
  80204d:	8b 55 10             	mov    0x10(%ebp),%edx
  802050:	89 54 24 08          	mov    %edx,0x8(%esp)
  802054:	8b 55 0c             	mov    0xc(%ebp),%edx
  802057:	89 54 24 04          	mov    %edx,0x4(%esp)
  80205b:	89 04 24             	mov    %eax,(%esp)
  80205e:	e8 5b 02 00 00       	call   8022be <nsipc_accept>
  802063:	85 c0                	test   %eax,%eax
  802065:	78 05                	js     80206c <accept+0x31>
		return r;
	return alloc_sockfd(r);
  802067:	e8 62 fe ff ff       	call   801ece <alloc_sockfd>
}
  80206c:	c9                   	leave  
  80206d:	8d 76 00             	lea    0x0(%esi),%esi
  802070:	c3                   	ret    
	...

00802080 <nsipc>:
// may be written back to nsipcbuf.
// type: request code, passed as the simple integer IPC value.
// Returns 0 if successful, < 0 on failure.
static int
nsipc(unsigned type)
{
  802080:	55                   	push   %ebp
  802081:	89 e5                	mov    %esp,%ebp
  802083:	83 ec 28             	sub    $0x28,%esp
    int r=0;
    envid_t from;
	if (debug)
		cprintf("[%08x] nsipc %d\n", env->env_id, type);

	ipc_send(envs[2].env_id, type, &nsipcbuf, PTE_P|PTE_W|PTE_U);
  802086:	8b 15 44 01 c0 ee    	mov    0xeec00144,%edx
  80208c:	c7 44 24 0c 07 00 00 	movl   $0x7,0xc(%esp)
  802093:	00 
  802094:	c7 44 24 08 00 60 80 	movl   $0x806000,0x8(%esp)
  80209b:	00 
  80209c:	89 44 24 04          	mov    %eax,0x4(%esp)
  8020a0:	89 14 24             	mov    %edx,(%esp)
  8020a3:	e8 08 09 00 00       	call   8029b0 <ipc_send>
	r=ipc_recv(&from, NULL, NULL);
  8020a8:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  8020af:	00 
  8020b0:	c7 44 24 04 00 00 00 	movl   $0x0,0x4(%esp)
  8020b7:	00 
  8020b8:	8d 45 f4             	lea    -0xc(%ebp),%eax
  8020bb:	89 04 24             	mov    %eax,(%esp)
  8020be:	e8 5f 09 00 00       	call   802a22 <ipc_recv>
    return r;
}
  8020c3:	c9                   	leave  
  8020c4:	c3                   	ret    

008020c5 <nsipc_socket>:
	return nsipc(NSREQ_SEND);
}

int
nsipc_socket(int domain, int type, int protocol)
{
  8020c5:	55                   	push   %ebp
  8020c6:	89 e5                	mov    %esp,%ebp
  8020c8:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.socket.req_domain = domain;
  8020cb:	8b 45 08             	mov    0x8(%ebp),%eax
  8020ce:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.socket.req_type = type;
  8020d3:	8b 45 0c             	mov    0xc(%ebp),%eax
  8020d6:	a3 04 60 80 00       	mov    %eax,0x806004
	nsipcbuf.socket.req_protocol = protocol;
  8020db:	8b 45 10             	mov    0x10(%ebp),%eax
  8020de:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SOCKET);
  8020e3:	b8 09 00 00 00       	mov    $0x9,%eax
  8020e8:	e8 93 ff ff ff       	call   802080 <nsipc>
}
  8020ed:	c9                   	leave  
  8020ee:	c3                   	ret    

008020ef <nsipc_listen>:
	return nsipc(NSREQ_CONNECT);
}

int
nsipc_listen(int s, int backlog)
{
  8020ef:	55                   	push   %ebp
  8020f0:	89 e5                	mov    %esp,%ebp
  8020f2:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.listen.req_s = s;
  8020f5:	8b 45 08             	mov    0x8(%ebp),%eax
  8020f8:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.listen.req_backlog = backlog;
  8020fd:	8b 45 0c             	mov    0xc(%ebp),%eax
  802100:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_LISTEN);
  802105:	b8 06 00 00 00       	mov    $0x6,%eax
  80210a:	e8 71 ff ff ff       	call   802080 <nsipc>
}
  80210f:	c9                   	leave  
  802110:	c3                   	ret    

00802111 <nsipc_close>:
	return nsipc(NSREQ_SHUTDOWN);
}

int
nsipc_close(int s)
{
  802111:	55                   	push   %ebp
  802112:	89 e5                	mov    %esp,%ebp
  802114:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.close.req_s = s;
  802117:	8b 45 08             	mov    0x8(%ebp),%eax
  80211a:	a3 00 60 80 00       	mov    %eax,0x806000
	return nsipc(NSREQ_CLOSE);
  80211f:	b8 04 00 00 00       	mov    $0x4,%eax
  802124:	e8 57 ff ff ff       	call   802080 <nsipc>
}
  802129:	c9                   	leave  
  80212a:	c3                   	ret    

0080212b <nsipc_shutdown>:
	return nsipc(NSREQ_BIND);
}

int
nsipc_shutdown(int s, int how)
{
  80212b:	55                   	push   %ebp
  80212c:	89 e5                	mov    %esp,%ebp
  80212e:	83 ec 08             	sub    $0x8,%esp
	nsipcbuf.shutdown.req_s = s;
  802131:	8b 45 08             	mov    0x8(%ebp),%eax
  802134:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.shutdown.req_how = how;
  802139:	8b 45 0c             	mov    0xc(%ebp),%eax
  80213c:	a3 04 60 80 00       	mov    %eax,0x806004
	return nsipc(NSREQ_SHUTDOWN);
  802141:	b8 03 00 00 00       	mov    $0x3,%eax
  802146:	e8 35 ff ff ff       	call   802080 <nsipc>
}
  80214b:	c9                   	leave  
  80214c:	c3                   	ret    

0080214d <nsipc_send>:
	return r;
}

int
nsipc_send(int s, const void *buf, int size, unsigned int flags)
{
  80214d:	55                   	push   %ebp
  80214e:	89 e5                	mov    %esp,%ebp
  802150:	53                   	push   %ebx
  802151:	83 ec 14             	sub    $0x14,%esp
  802154:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.send.req_s = s;
  802157:	8b 45 08             	mov    0x8(%ebp),%eax
  80215a:	a3 00 60 80 00       	mov    %eax,0x806000
	assert(size < 1600);
  80215f:	81 fb 3f 06 00 00    	cmp    $0x63f,%ebx
  802165:	7e 24                	jle    80218b <nsipc_send+0x3e>
  802167:	c7 44 24 0c f4 32 80 	movl   $0x8032f4,0xc(%esp)
  80216e:	00 
  80216f:	c7 44 24 08 00 33 80 	movl   $0x803300,0x8(%esp)
  802176:	00 
  802177:	c7 44 24 04 69 00 00 	movl   $0x69,0x4(%esp)
  80217e:	00 
  80217f:	c7 04 24 15 33 80 00 	movl   $0x803315,(%esp)
  802186:	e8 29 07 00 00       	call   8028b4 <_panic>
	memmove(&nsipcbuf.send.req_buf, buf, size);
  80218b:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  80218f:	8b 45 0c             	mov    0xc(%ebp),%eax
  802192:	89 44 24 04          	mov    %eax,0x4(%esp)
  802196:	c7 04 24 0c 60 80 00 	movl   $0x80600c,(%esp)
  80219d:	e8 b3 e8 ff ff       	call   800a55 <memmove>
	nsipcbuf.send.req_size = size;
  8021a2:	89 1d 04 60 80 00    	mov    %ebx,0x806004
	nsipcbuf.send.req_flags = flags;
  8021a8:	8b 45 14             	mov    0x14(%ebp),%eax
  8021ab:	a3 08 60 80 00       	mov    %eax,0x806008
	return nsipc(NSREQ_SEND);
  8021b0:	b8 08 00 00 00       	mov    $0x8,%eax
  8021b5:	e8 c6 fe ff ff       	call   802080 <nsipc>
}
  8021ba:	83 c4 14             	add    $0x14,%esp
  8021bd:	5b                   	pop    %ebx
  8021be:	5d                   	pop    %ebp
  8021bf:	c3                   	ret    

008021c0 <nsipc_recv>:
	return nsipc(NSREQ_LISTEN);
}

int
nsipc_recv(int s, void *mem, int len, unsigned int flags)
{
  8021c0:	55                   	push   %ebp
  8021c1:	89 e5                	mov    %esp,%ebp
  8021c3:	56                   	push   %esi
  8021c4:	53                   	push   %ebx
  8021c5:	83 ec 10             	sub    $0x10,%esp
  8021c8:	8b 75 10             	mov    0x10(%ebp),%esi
	int r;

	nsipcbuf.recv.req_s = s;
  8021cb:	8b 45 08             	mov    0x8(%ebp),%eax
  8021ce:	a3 00 60 80 00       	mov    %eax,0x806000
	nsipcbuf.recv.req_len = len;
  8021d3:	89 35 04 60 80 00    	mov    %esi,0x806004
	nsipcbuf.recv.req_flags = flags;
  8021d9:	8b 45 14             	mov    0x14(%ebp),%eax
  8021dc:	a3 08 60 80 00       	mov    %eax,0x806008

	if ((r = nsipc(NSREQ_RECV)) >= 0) {
  8021e1:	b8 07 00 00 00       	mov    $0x7,%eax
  8021e6:	e8 95 fe ff ff       	call   802080 <nsipc>
  8021eb:	89 c3                	mov    %eax,%ebx
  8021ed:	85 c0                	test   %eax,%eax
  8021ef:	78 46                	js     802237 <nsipc_recv+0x77>
		assert(r < 1600 && r <= len);
  8021f1:	3d 3f 06 00 00       	cmp    $0x63f,%eax
  8021f6:	7f 04                	jg     8021fc <nsipc_recv+0x3c>
  8021f8:	39 c6                	cmp    %eax,%esi
  8021fa:	7d 24                	jge    802220 <nsipc_recv+0x60>
  8021fc:	c7 44 24 0c 21 33 80 	movl   $0x803321,0xc(%esp)
  802203:	00 
  802204:	c7 44 24 08 00 33 80 	movl   $0x803300,0x8(%esp)
  80220b:	00 
  80220c:	c7 44 24 04 5e 00 00 	movl   $0x5e,0x4(%esp)
  802213:	00 
  802214:	c7 04 24 15 33 80 00 	movl   $0x803315,(%esp)
  80221b:	e8 94 06 00 00       	call   8028b4 <_panic>
		memmove(mem, nsipcbuf.recvRet.ret_buf, r);
  802220:	89 44 24 08          	mov    %eax,0x8(%esp)
  802224:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  80222b:	00 
  80222c:	8b 45 0c             	mov    0xc(%ebp),%eax
  80222f:	89 04 24             	mov    %eax,(%esp)
  802232:	e8 1e e8 ff ff       	call   800a55 <memmove>
	}

	return r;
}
  802237:	89 d8                	mov    %ebx,%eax
  802239:	83 c4 10             	add    $0x10,%esp
  80223c:	5b                   	pop    %ebx
  80223d:	5e                   	pop    %esi
  80223e:	5d                   	pop    %ebp
  80223f:	c3                   	ret    

00802240 <nsipc_connect>:
	return nsipc(NSREQ_CLOSE);
}

int
nsipc_connect(int s, const struct sockaddr *name, socklen_t namelen)
{
  802240:	55                   	push   %ebp
  802241:	89 e5                	mov    %esp,%ebp
  802243:	53                   	push   %ebx
  802244:	83 ec 14             	sub    $0x14,%esp
  802247:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.connect.req_s = s;
  80224a:	8b 45 08             	mov    0x8(%ebp),%eax
  80224d:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.connect.req_name, name, namelen);
  802252:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802256:	8b 45 0c             	mov    0xc(%ebp),%eax
  802259:	89 44 24 04          	mov    %eax,0x4(%esp)
  80225d:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  802264:	e8 ec e7 ff ff       	call   800a55 <memmove>
	nsipcbuf.connect.req_namelen = namelen;
  802269:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_CONNECT);
  80226f:	b8 05 00 00 00       	mov    $0x5,%eax
  802274:	e8 07 fe ff ff       	call   802080 <nsipc>
}
  802279:	83 c4 14             	add    $0x14,%esp
  80227c:	5b                   	pop    %ebx
  80227d:	5d                   	pop    %ebp
  80227e:	c3                   	ret    

0080227f <nsipc_bind>:
	return r;
}

int
nsipc_bind(int s, struct sockaddr *name, socklen_t namelen)
{
  80227f:	55                   	push   %ebp
  802280:	89 e5                	mov    %esp,%ebp
  802282:	53                   	push   %ebx
  802283:	83 ec 14             	sub    $0x14,%esp
  802286:	8b 5d 10             	mov    0x10(%ebp),%ebx
	nsipcbuf.bind.req_s = s;
  802289:	8b 45 08             	mov    0x8(%ebp),%eax
  80228c:	a3 00 60 80 00       	mov    %eax,0x806000
	memmove(&nsipcbuf.bind.req_name, name, namelen);
  802291:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802295:	8b 45 0c             	mov    0xc(%ebp),%eax
  802298:	89 44 24 04          	mov    %eax,0x4(%esp)
  80229c:	c7 04 24 04 60 80 00 	movl   $0x806004,(%esp)
  8022a3:	e8 ad e7 ff ff       	call   800a55 <memmove>
	nsipcbuf.bind.req_namelen = namelen;
  8022a8:	89 1d 14 60 80 00    	mov    %ebx,0x806014
	return nsipc(NSREQ_BIND);
  8022ae:	b8 02 00 00 00       	mov    $0x2,%eax
  8022b3:	e8 c8 fd ff ff       	call   802080 <nsipc>
}
  8022b8:	83 c4 14             	add    $0x14,%esp
  8022bb:	5b                   	pop    %ebx
  8022bc:	5d                   	pop    %ebp
  8022bd:	c3                   	ret    

008022be <nsipc_accept>:
    return r;
}

int
nsipc_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
  8022be:	55                   	push   %ebp
  8022bf:	89 e5                	mov    %esp,%ebp
  8022c1:	83 ec 18             	sub    $0x18,%esp
  8022c4:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  8022c7:	89 75 fc             	mov    %esi,-0x4(%ebp)
	int r;
	
	nsipcbuf.accept.req_s = s;
  8022ca:	8b 45 08             	mov    0x8(%ebp),%eax
  8022cd:	a3 00 60 80 00       	mov    %eax,0x806000
	if ((r = nsipc(NSREQ_ACCEPT)) >= 0) {
  8022d2:	b8 01 00 00 00       	mov    $0x1,%eax
  8022d7:	e8 a4 fd ff ff       	call   802080 <nsipc>
  8022dc:	89 c3                	mov    %eax,%ebx
  8022de:	85 c0                	test   %eax,%eax
  8022e0:	78 25                	js     802307 <nsipc_accept+0x49>
		struct Nsret_accept *ret = &nsipcbuf.acceptRet;
		memmove(addr, &ret->ret_addr, ret->ret_addrlen);
  8022e2:	be 10 60 80 00       	mov    $0x806010,%esi
  8022e7:	8b 06                	mov    (%esi),%eax
  8022e9:	89 44 24 08          	mov    %eax,0x8(%esp)
  8022ed:	c7 44 24 04 00 60 80 	movl   $0x806000,0x4(%esp)
  8022f4:	00 
  8022f5:	8b 45 0c             	mov    0xc(%ebp),%eax
  8022f8:	89 04 24             	mov    %eax,(%esp)
  8022fb:	e8 55 e7 ff ff       	call   800a55 <memmove>
		*addrlen = ret->ret_addrlen;
  802300:	8b 16                	mov    (%esi),%edx
  802302:	8b 45 10             	mov    0x10(%ebp),%eax
  802305:	89 10                	mov    %edx,(%eax)
	}
	return r;
}
  802307:	89 d8                	mov    %ebx,%eax
  802309:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  80230c:	8b 75 fc             	mov    -0x4(%ebp),%esi
  80230f:	89 ec                	mov    %ebp,%esp
  802311:	5d                   	pop    %ebp
  802312:	c3                   	ret    
	...

00802320 <devpipe_stat>:
	return i;
}

static int
devpipe_stat(struct Fd *fd, struct Stat *stat)
{
  802320:	55                   	push   %ebp
  802321:	89 e5                	mov    %esp,%ebp
  802323:	83 ec 18             	sub    $0x18,%esp
  802326:	89 5d f8             	mov    %ebx,-0x8(%ebp)
  802329:	89 75 fc             	mov    %esi,-0x4(%ebp)
  80232c:	8b 75 0c             	mov    0xc(%ebp),%esi
	struct Pipe *p = (struct Pipe*) fd2data(fd);
  80232f:	8b 45 08             	mov    0x8(%ebp),%eax
  802332:	89 04 24             	mov    %eax,(%esp)
  802335:	e8 f6 f1 ff ff       	call   801530 <fd2data>
  80233a:	89 c3                	mov    %eax,%ebx
	strcpy(stat->st_name, "<pipe>");
  80233c:	c7 44 24 04 36 33 80 	movl   $0x803336,0x4(%esp)
  802343:	00 
  802344:	89 34 24             	mov    %esi,(%esp)
  802347:	e8 4e e5 ff ff       	call   80089a <strcpy>
	stat->st_size = p->p_wpos - p->p_rpos;
  80234c:	8b 43 04             	mov    0x4(%ebx),%eax
  80234f:	2b 03                	sub    (%ebx),%eax
  802351:	89 86 80 00 00 00    	mov    %eax,0x80(%esi)
	stat->st_isdir = 0;
  802357:	c7 86 84 00 00 00 00 	movl   $0x0,0x84(%esi)
  80235e:	00 00 00 
	stat->st_dev = &devpipe;
  802361:	c7 86 88 00 00 00 3c 	movl   $0x80703c,0x88(%esi)
  802368:	70 80 00 
	return 0;
}
  80236b:	b8 00 00 00 00       	mov    $0x0,%eax
  802370:	8b 5d f8             	mov    -0x8(%ebp),%ebx
  802373:	8b 75 fc             	mov    -0x4(%ebp),%esi
  802376:	89 ec                	mov    %ebp,%esp
  802378:	5d                   	pop    %ebp
  802379:	c3                   	ret    

0080237a <devpipe_close>:

static int
devpipe_close(struct Fd *fd)
{
  80237a:	55                   	push   %ebp
  80237b:	89 e5                	mov    %esp,%ebp
  80237d:	53                   	push   %ebx
  80237e:	83 ec 14             	sub    $0x14,%esp
  802381:	8b 5d 08             	mov    0x8(%ebp),%ebx
	(void) sys_page_unmap(0, fd);
  802384:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802388:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80238f:	e8 a6 eb ff ff       	call   800f3a <sys_page_unmap>
	return sys_page_unmap(0, fd2data(fd));
  802394:	89 1c 24             	mov    %ebx,(%esp)
  802397:	e8 94 f1 ff ff       	call   801530 <fd2data>
  80239c:	89 44 24 04          	mov    %eax,0x4(%esp)
  8023a0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8023a7:	e8 8e eb ff ff       	call   800f3a <sys_page_unmap>
}
  8023ac:	83 c4 14             	add    $0x14,%esp
  8023af:	5b                   	pop    %ebx
  8023b0:	5d                   	pop    %ebp
  8023b1:	c3                   	ret    

008023b2 <_pipeisclosed>:
	return r;
}

static int
_pipeisclosed(struct Fd *fd, struct Pipe *p)
{
  8023b2:	55                   	push   %ebp
  8023b3:	89 e5                	mov    %esp,%ebp
  8023b5:	57                   	push   %edi
  8023b6:	56                   	push   %esi
  8023b7:	53                   	push   %ebx
  8023b8:	83 ec 2c             	sub    $0x2c,%esp
  8023bb:	89 c7                	mov    %eax,%edi
  8023bd:	89 55 e4             	mov    %edx,-0x1c(%ebp)
	int n, nn, ret;

	while (1) {
		n = env->env_runs;
  8023c0:	a1 74 70 80 00       	mov    0x807074,%eax
  8023c5:	8b 58 58             	mov    0x58(%eax),%ebx
		ret = pageref(fd) == pageref(p);
  8023c8:	89 3c 24             	mov    %edi,(%esp)
  8023cb:	e8 a4 06 00 00       	call   802a74 <pageref>
  8023d0:	89 c6                	mov    %eax,%esi
  8023d2:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8023d5:	89 04 24             	mov    %eax,(%esp)
  8023d8:	e8 97 06 00 00       	call   802a74 <pageref>
  8023dd:	39 c6                	cmp    %eax,%esi
  8023df:	0f 94 c0             	sete   %al
  8023e2:	0f b6 c0             	movzbl %al,%eax
		nn = env->env_runs;
  8023e5:	8b 15 74 70 80 00    	mov    0x807074,%edx
  8023eb:	8b 4a 58             	mov    0x58(%edx),%ecx
		if (n == nn)
  8023ee:	39 cb                	cmp    %ecx,%ebx
  8023f0:	75 08                	jne    8023fa <_pipeisclosed+0x48>
			return ret;
		if (n != nn && ret == 1)
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
	}
}
  8023f2:	83 c4 2c             	add    $0x2c,%esp
  8023f5:	5b                   	pop    %ebx
  8023f6:	5e                   	pop    %esi
  8023f7:	5f                   	pop    %edi
  8023f8:	5d                   	pop    %ebp
  8023f9:	c3                   	ret    
		n = env->env_runs;
		ret = pageref(fd) == pageref(p);
		nn = env->env_runs;
		if (n == nn)
			return ret;
		if (n != nn && ret == 1)
  8023fa:	83 f8 01             	cmp    $0x1,%eax
  8023fd:	75 c1                	jne    8023c0 <_pipeisclosed+0xe>
			cprintf("pipe race avoided\n", n, env->env_runs, ret);
  8023ff:	8b 52 58             	mov    0x58(%edx),%edx
  802402:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802406:	89 54 24 08          	mov    %edx,0x8(%esp)
  80240a:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  80240e:	c7 04 24 3d 33 80 00 	movl   $0x80333d,(%esp)
  802415:	e8 af dd ff ff       	call   8001c9 <cprintf>
  80241a:	eb a4                	jmp    8023c0 <_pipeisclosed+0xe>

0080241c <devpipe_write>:
	return i;
}

static ssize_t
devpipe_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80241c:	55                   	push   %ebp
  80241d:	89 e5                	mov    %esp,%ebp
  80241f:	57                   	push   %edi
  802420:	56                   	push   %esi
  802421:	53                   	push   %ebx
  802422:	83 ec 1c             	sub    $0x1c,%esp
  802425:	8b 75 08             	mov    0x8(%ebp),%esi
	const uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*) fd2data(fd);
  802428:	89 34 24             	mov    %esi,(%esp)
  80242b:	e8 00 f1 ff ff       	call   801530 <fd2data>
  802430:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802432:	bf 00 00 00 00       	mov    $0x0,%edi
  802437:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  80243b:	75 54                	jne    802491 <devpipe_write+0x75>
  80243d:	eb 60                	jmp    80249f <devpipe_write+0x83>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
			// pipe is full
			// if all the readers are gone
			// (it's only writers like us now),
			// note eof
			if (_pipeisclosed(fd, p))
  80243f:	89 da                	mov    %ebx,%edx
  802441:	89 f0                	mov    %esi,%eax
  802443:	e8 6a ff ff ff       	call   8023b2 <_pipeisclosed>
  802448:	85 c0                	test   %eax,%eax
  80244a:	74 07                	je     802453 <devpipe_write+0x37>
  80244c:	b8 00 00 00 00       	mov    $0x0,%eax
  802451:	eb 53                	jmp    8024a6 <devpipe_write+0x8a>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_write yield\n");
			sys_yield();
  802453:	90                   	nop
  802454:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802458:	e8 f8 eb ff ff       	call   801055 <sys_yield>
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  80245d:	8b 43 04             	mov    0x4(%ebx),%eax
  802460:	8b 13                	mov    (%ebx),%edx
  802462:	83 c2 20             	add    $0x20,%edx
  802465:	39 d0                	cmp    %edx,%eax
  802467:	73 d6                	jae    80243f <devpipe_write+0x23>
				cprintf("devpipe_write yield\n");
			sys_yield();
		}
		// there's room for a byte.  store it.
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
  802469:	89 c2                	mov    %eax,%edx
  80246b:	c1 fa 1f             	sar    $0x1f,%edx
  80246e:	c1 ea 1b             	shr    $0x1b,%edx
  802471:	01 d0                	add    %edx,%eax
  802473:	83 e0 1f             	and    $0x1f,%eax
  802476:	29 d0                	sub    %edx,%eax
  802478:	89 c2                	mov    %eax,%edx
  80247a:	8b 4d 0c             	mov    0xc(%ebp),%ecx
  80247d:	0f b6 04 39          	movzbl (%ecx,%edi,1),%eax
  802481:	88 44 13 08          	mov    %al,0x8(%ebx,%edx,1)
		p->p_wpos++;
  802485:	83 43 04 01          	addl   $0x1,0x4(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_write %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802489:	83 c7 01             	add    $0x1,%edi
  80248c:	39 7d 10             	cmp    %edi,0x10(%ebp)
  80248f:	76 13                	jbe    8024a4 <devpipe_write+0x88>
		while (p->p_wpos >= p->p_rpos + sizeof(p->p_buf)) {
  802491:	8b 43 04             	mov    0x4(%ebx),%eax
  802494:	8b 13                	mov    (%ebx),%edx
  802496:	83 c2 20             	add    $0x20,%edx
  802499:	39 d0                	cmp    %edx,%eax
  80249b:	73 a2                	jae    80243f <devpipe_write+0x23>
  80249d:	eb ca                	jmp    802469 <devpipe_write+0x4d>
  80249f:	bf 00 00 00 00       	mov    $0x0,%edi
		// wait to increment wpos until the byte is stored!
		p->p_buf[p->p_wpos % PIPEBUFSIZ] = buf[i];
		p->p_wpos++;
	}
	
	return i;
  8024a4:	89 f8                	mov    %edi,%eax
}
  8024a6:	83 c4 1c             	add    $0x1c,%esp
  8024a9:	5b                   	pop    %ebx
  8024aa:	5e                   	pop    %esi
  8024ab:	5f                   	pop    %edi
  8024ac:	5d                   	pop    %ebp
  8024ad:	c3                   	ret    

008024ae <devpipe_read>:
	return _pipeisclosed(fd, p);
}

static ssize_t
devpipe_read(struct Fd *fd, void *vbuf, size_t n)
{
  8024ae:	55                   	push   %ebp
  8024af:	89 e5                	mov    %esp,%ebp
  8024b1:	83 ec 28             	sub    $0x28,%esp
  8024b4:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  8024b7:	89 75 f8             	mov    %esi,-0x8(%ebp)
  8024ba:	89 7d fc             	mov    %edi,-0x4(%ebp)
  8024bd:	8b 7d 08             	mov    0x8(%ebp),%edi
	uint8_t *buf;
	size_t i;
	struct Pipe *p;

	p = (struct Pipe*)fd2data(fd);
  8024c0:	89 3c 24             	mov    %edi,(%esp)
  8024c3:	e8 68 f0 ff ff       	call   801530 <fd2data>
  8024c8:	89 c3                	mov    %eax,%ebx
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  8024ca:	be 00 00 00 00       	mov    $0x0,%esi
  8024cf:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8024d3:	75 4c                	jne    802521 <devpipe_read+0x73>
  8024d5:	eb 5b                	jmp    802532 <devpipe_read+0x84>
		while (p->p_rpos == p->p_wpos) {
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
				return i;
  8024d7:	89 f0                	mov    %esi,%eax
  8024d9:	eb 5e                	jmp    802539 <devpipe_read+0x8b>
			// if all the writers are gone, note eof
			if (_pipeisclosed(fd, p))
  8024db:	89 da                	mov    %ebx,%edx
  8024dd:	89 f8                	mov    %edi,%eax
  8024df:	90                   	nop
  8024e0:	e8 cd fe ff ff       	call   8023b2 <_pipeisclosed>
  8024e5:	85 c0                	test   %eax,%eax
  8024e7:	74 07                	je     8024f0 <devpipe_read+0x42>
  8024e9:	b8 00 00 00 00       	mov    $0x0,%eax
  8024ee:	eb 49                	jmp    802539 <devpipe_read+0x8b>
				return 0;
			// yield and see what happens
			if (debug)
				cprintf("devpipe_read yield\n");
			sys_yield();
  8024f0:	e8 60 eb ff ff       	call   801055 <sys_yield>
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
		while (p->p_rpos == p->p_wpos) {
  8024f5:	8b 03                	mov    (%ebx),%eax
  8024f7:	3b 43 04             	cmp    0x4(%ebx),%eax
  8024fa:	74 df                	je     8024db <devpipe_read+0x2d>
				cprintf("devpipe_read yield\n");
			sys_yield();
		}
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
  8024fc:	89 c2                	mov    %eax,%edx
  8024fe:	c1 fa 1f             	sar    $0x1f,%edx
  802501:	c1 ea 1b             	shr    $0x1b,%edx
  802504:	01 d0                	add    %edx,%eax
  802506:	83 e0 1f             	and    $0x1f,%eax
  802509:	29 d0                	sub    %edx,%eax
  80250b:	0f b6 44 03 08       	movzbl 0x8(%ebx,%eax,1),%eax
  802510:	8b 55 0c             	mov    0xc(%ebp),%edx
  802513:	88 04 32             	mov    %al,(%edx,%esi,1)
		p->p_rpos++;
  802516:	83 03 01             	addl   $0x1,(%ebx)
	if (debug)
		cprintf("[%08x] devpipe_read %08x %d rpos %d wpos %d\n",
			env->env_id, vpt[VPN(p)], n, p->p_rpos, p->p_wpos);

	buf = vbuf;
	for (i = 0; i < n; i++) {
  802519:	83 c6 01             	add    $0x1,%esi
  80251c:	39 75 10             	cmp    %esi,0x10(%ebp)
  80251f:	76 16                	jbe    802537 <devpipe_read+0x89>
		while (p->p_rpos == p->p_wpos) {
  802521:	8b 03                	mov    (%ebx),%eax
  802523:	3b 43 04             	cmp    0x4(%ebx),%eax
  802526:	75 d4                	jne    8024fc <devpipe_read+0x4e>
			// pipe is empty
			// if we got any data, return it
			if (i > 0)
  802528:	85 f6                	test   %esi,%esi
  80252a:	75 ab                	jne    8024d7 <devpipe_read+0x29>
  80252c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802530:	eb a9                	jmp    8024db <devpipe_read+0x2d>
  802532:	be 00 00 00 00       	mov    $0x0,%esi
		// there's a byte.  take it.
		// wait to increment rpos until the byte is taken!
		buf[i] = p->p_buf[p->p_rpos % PIPEBUFSIZ];
		p->p_rpos++;
	}
	return i;
  802537:	89 f0                	mov    %esi,%eax
}
  802539:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  80253c:	8b 75 f8             	mov    -0x8(%ebp),%esi
  80253f:	8b 7d fc             	mov    -0x4(%ebp),%edi
  802542:	89 ec                	mov    %ebp,%esp
  802544:	5d                   	pop    %ebp
  802545:	c3                   	ret    

00802546 <pipeisclosed>:
	}
}

int
pipeisclosed(int fdnum)
{
  802546:	55                   	push   %ebp
  802547:	89 e5                	mov    %esp,%ebp
  802549:	83 ec 28             	sub    $0x28,%esp
	struct Fd *fd;
	struct Pipe *p;
	int r;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  80254c:	8d 45 f4             	lea    -0xc(%ebp),%eax
  80254f:	89 44 24 04          	mov    %eax,0x4(%esp)
  802553:	8b 45 08             	mov    0x8(%ebp),%eax
  802556:	89 04 24             	mov    %eax,(%esp)
  802559:	e8 5f f0 ff ff       	call   8015bd <fd_lookup>
  80255e:	85 c0                	test   %eax,%eax
  802560:	78 15                	js     802577 <pipeisclosed+0x31>
		return r;
	p = (struct Pipe*) fd2data(fd);
  802562:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802565:	89 04 24             	mov    %eax,(%esp)
  802568:	e8 c3 ef ff ff       	call   801530 <fd2data>
	return _pipeisclosed(fd, p);
  80256d:	89 c2                	mov    %eax,%edx
  80256f:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802572:	e8 3b fe ff ff       	call   8023b2 <_pipeisclosed>
}
  802577:	c9                   	leave  
  802578:	c3                   	ret    

00802579 <pipe>:
	uint8_t p_buf[PIPEBUFSIZ];	// data buffer
};

int
pipe(int pfd[2])
{
  802579:	55                   	push   %ebp
  80257a:	89 e5                	mov    %esp,%ebp
  80257c:	83 ec 48             	sub    $0x48,%esp
  80257f:	89 5d f4             	mov    %ebx,-0xc(%ebp)
  802582:	89 75 f8             	mov    %esi,-0x8(%ebp)
  802585:	89 7d fc             	mov    %edi,-0x4(%ebp)
  802588:	8b 7d 08             	mov    0x8(%ebp),%edi
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  80258b:	8d 45 e4             	lea    -0x1c(%ebp),%eax
  80258e:	89 04 24             	mov    %eax,(%esp)
  802591:	e8 b5 ef ff ff       	call   80154b <fd_alloc>
  802596:	89 c3                	mov    %eax,%ebx
  802598:	85 c0                	test   %eax,%eax
  80259a:	0f 88 42 01 00 00    	js     8026e2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8025a0:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8025a7:	00 
  8025a8:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8025ab:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025af:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025b6:	e8 3b ea ff ff       	call   800ff6 <sys_page_alloc>
  8025bb:	89 c3                	mov    %eax,%ebx
	int r;
	struct Fd *fd0, *fd1;
	void *va;

	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
  8025bd:	85 c0                	test   %eax,%eax
  8025bf:	0f 88 1d 01 00 00    	js     8026e2 <pipe+0x169>
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8025c5:	8d 45 e0             	lea    -0x20(%ebp),%eax
  8025c8:	89 04 24             	mov    %eax,(%esp)
  8025cb:	e8 7b ef ff ff       	call   80154b <fd_alloc>
  8025d0:	89 c3                	mov    %eax,%ebx
  8025d2:	85 c0                	test   %eax,%eax
  8025d4:	0f 88 f5 00 00 00    	js     8026cf <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  8025da:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  8025e1:	00 
  8025e2:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8025e5:	89 44 24 04          	mov    %eax,0x4(%esp)
  8025e9:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8025f0:	e8 01 ea ff ff       	call   800ff6 <sys_page_alloc>
  8025f5:	89 c3                	mov    %eax,%ebx
	// allocate the file descriptor table entries
	if ((r = fd_alloc(&fd0)) < 0
	    || (r = sys_page_alloc(0, fd0, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err;

	if ((r = fd_alloc(&fd1)) < 0
  8025f7:	85 c0                	test   %eax,%eax
  8025f9:	0f 88 d0 00 00 00    	js     8026cf <pipe+0x156>
	    || (r = sys_page_alloc(0, fd1, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
		goto err1;

	// allocate the pipe structure as first data page in both
	va = fd2data(fd0);
  8025ff:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  802602:	89 04 24             	mov    %eax,(%esp)
  802605:	e8 26 ef ff ff       	call   801530 <fd2data>
  80260a:	89 c6                	mov    %eax,%esi
	if ((r = sys_page_alloc(0, va, PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80260c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802613:	00 
  802614:	89 44 24 04          	mov    %eax,0x4(%esp)
  802618:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  80261f:	e8 d2 e9 ff ff       	call   800ff6 <sys_page_alloc>
  802624:	89 c3                	mov    %eax,%ebx
  802626:	85 c0                	test   %eax,%eax
  802628:	0f 88 8e 00 00 00    	js     8026bc <pipe+0x143>
		goto err2;
	if ((r = sys_page_map(0, va, 0, fd2data(fd1), PTE_P|PTE_W|PTE_U|PTE_SHARE)) < 0)
  80262e:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802631:	89 04 24             	mov    %eax,(%esp)
  802634:	e8 f7 ee ff ff       	call   801530 <fd2data>
  802639:	c7 44 24 10 07 04 00 	movl   $0x407,0x10(%esp)
  802640:	00 
  802641:	89 44 24 0c          	mov    %eax,0xc(%esp)
  802645:	c7 44 24 08 00 00 00 	movl   $0x0,0x8(%esp)
  80264c:	00 
  80264d:	89 74 24 04          	mov    %esi,0x4(%esp)
  802651:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802658:	e8 3b e9 ff ff       	call   800f98 <sys_page_map>
  80265d:	89 c3                	mov    %eax,%ebx
  80265f:	85 c0                	test   %eax,%eax
  802661:	78 49                	js     8026ac <pipe+0x133>
		goto err3;

	// set up fd structures
	fd0->fd_dev_id = devpipe.dev_id;
  802663:	b8 3c 70 80 00       	mov    $0x80703c,%eax
  802668:	8b 08                	mov    (%eax),%ecx
  80266a:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  80266d:	89 0a                	mov    %ecx,(%edx)
	fd0->fd_omode = O_RDONLY;
  80266f:	8b 55 e4             	mov    -0x1c(%ebp),%edx
  802672:	c7 42 08 00 00 00 00 	movl   $0x0,0x8(%edx)

	fd1->fd_dev_id = devpipe.dev_id;
  802679:	8b 10                	mov    (%eax),%edx
  80267b:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80267e:	89 10                	mov    %edx,(%eax)
	fd1->fd_omode = O_WRONLY;
  802680:	8b 45 e0             	mov    -0x20(%ebp),%eax
  802683:	c7 40 08 01 00 00 00 	movl   $0x1,0x8(%eax)

	if (debug)
		cprintf("[%08x] pipecreate %08x\n", env->env_id, vpt[VPN(va)]);

	pfd[0] = fd2num(fd0);
  80268a:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  80268d:	89 04 24             	mov    %eax,(%esp)
  802690:	e8 8b ee ff ff       	call   801520 <fd2num>
  802695:	89 07                	mov    %eax,(%edi)
	pfd[1] = fd2num(fd1);
  802697:	8b 45 e0             	mov    -0x20(%ebp),%eax
  80269a:	89 04 24             	mov    %eax,(%esp)
  80269d:	e8 7e ee ff ff       	call   801520 <fd2num>
  8026a2:	89 47 04             	mov    %eax,0x4(%edi)
  8026a5:	bb 00 00 00 00       	mov    $0x0,%ebx
	return 0;
  8026aa:	eb 36                	jmp    8026e2 <pipe+0x169>

    err3:
	sys_page_unmap(0, va);
  8026ac:	89 74 24 04          	mov    %esi,0x4(%esp)
  8026b0:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026b7:	e8 7e e8 ff ff       	call   800f3a <sys_page_unmap>
    err2:
	sys_page_unmap(0, fd1);
  8026bc:	8b 45 e0             	mov    -0x20(%ebp),%eax
  8026bf:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026c3:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026ca:	e8 6b e8 ff ff       	call   800f3a <sys_page_unmap>
    err1:
	sys_page_unmap(0, fd0);
  8026cf:	8b 45 e4             	mov    -0x1c(%ebp),%eax
  8026d2:	89 44 24 04          	mov    %eax,0x4(%esp)
  8026d6:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  8026dd:	e8 58 e8 ff ff       	call   800f3a <sys_page_unmap>
    err:
	return r;
}
  8026e2:	89 d8                	mov    %ebx,%eax
  8026e4:	8b 5d f4             	mov    -0xc(%ebp),%ebx
  8026e7:	8b 75 f8             	mov    -0x8(%ebp),%esi
  8026ea:	8b 7d fc             	mov    -0x4(%ebp),%edi
  8026ed:	89 ec                	mov    %ebp,%esp
  8026ef:	5d                   	pop    %ebp
  8026f0:	c3                   	ret    
	...

00802700 <devcons_close>:
	return tot;
}

static int
devcons_close(struct Fd *fd)
{
  802700:	55                   	push   %ebp
  802701:	89 e5                	mov    %esp,%ebp
	USED(fd);

	return 0;
}
  802703:	b8 00 00 00 00       	mov    $0x0,%eax
  802708:	5d                   	pop    %ebp
  802709:	c3                   	ret    

0080270a <devcons_stat>:

static int
devcons_stat(struct Fd *fd, struct Stat *stat)
{
  80270a:	55                   	push   %ebp
  80270b:	89 e5                	mov    %esp,%ebp
  80270d:	83 ec 18             	sub    $0x18,%esp
	strcpy(stat->st_name, "<cons>");
  802710:	c7 44 24 04 55 33 80 	movl   $0x803355,0x4(%esp)
  802717:	00 
  802718:	8b 45 0c             	mov    0xc(%ebp),%eax
  80271b:	89 04 24             	mov    %eax,(%esp)
  80271e:	e8 77 e1 ff ff       	call   80089a <strcpy>
	return 0;
}
  802723:	b8 00 00 00 00       	mov    $0x0,%eax
  802728:	c9                   	leave  
  802729:	c3                   	ret    

0080272a <devcons_write>:
	return 1;
}

static ssize_t
devcons_write(struct Fd *fd, const void *vbuf, size_t n)
{
  80272a:	55                   	push   %ebp
  80272b:	89 e5                	mov    %esp,%ebp
  80272d:	57                   	push   %edi
  80272e:	56                   	push   %esi
  80272f:	53                   	push   %ebx
  802730:	81 ec 9c 00 00 00    	sub    $0x9c,%esp
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  802736:	b8 00 00 00 00       	mov    $0x0,%eax
  80273b:	be 00 00 00 00       	mov    $0x0,%esi
  802740:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  802744:	74 41                	je     802787 <devcons_write+0x5d>
		m = n - tot;
		if (m > sizeof(buf) - 1)
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  802746:	8d bd 68 ff ff ff    	lea    -0x98(%ebp),%edi
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
		m = n - tot;
  80274c:	8b 5d 10             	mov    0x10(%ebp),%ebx
  80274f:	29 c3                	sub    %eax,%ebx
		if (m > sizeof(buf) - 1)
  802751:	81 fb 80 00 00 00    	cmp    $0x80,%ebx
  802757:	ba 7f 00 00 00       	mov    $0x7f,%edx
  80275c:	0f 43 da             	cmovae %edx,%ebx
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
  80275f:	89 5c 24 08          	mov    %ebx,0x8(%esp)
  802763:	03 45 0c             	add    0xc(%ebp),%eax
  802766:	89 44 24 04          	mov    %eax,0x4(%esp)
  80276a:	89 3c 24             	mov    %edi,(%esp)
  80276d:	e8 e3 e2 ff ff       	call   800a55 <memmove>
		sys_cputs(buf, m);
  802772:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  802776:	89 3c 24             	mov    %edi,(%esp)
  802779:	e8 12 e5 ff ff       	call   800c90 <sys_cputs>
	int tot, m;
	char buf[128];

	// mistake: have to nul-terminate arg to sys_cputs, 
	// so we have to copy vbuf into buf in chunks and nul-terminate.
	for (tot = 0; tot < n; tot += m) {
  80277e:	01 de                	add    %ebx,%esi
  802780:	89 f0                	mov    %esi,%eax
  802782:	3b 75 10             	cmp    0x10(%ebp),%esi
  802785:	72 c5                	jb     80274c <devcons_write+0x22>
			m = sizeof(buf) - 1;
		memmove(buf, (char*)vbuf + tot, m);
		sys_cputs(buf, m);
	}
	return tot;
}
  802787:	89 f0                	mov    %esi,%eax
  802789:	81 c4 9c 00 00 00    	add    $0x9c,%esp
  80278f:	5b                   	pop    %ebx
  802790:	5e                   	pop    %esi
  802791:	5f                   	pop    %edi
  802792:	5d                   	pop    %ebp
  802793:	c3                   	ret    

00802794 <cputchar>:
#include <inc/string.h>
#include <inc/lib.h>

void
cputchar(int ch)
{
  802794:	55                   	push   %ebp
  802795:	89 e5                	mov    %esp,%ebp
  802797:	83 ec 28             	sub    $0x28,%esp
	char c = ch;
  80279a:	8b 45 08             	mov    0x8(%ebp),%eax
  80279d:	88 45 f7             	mov    %al,-0x9(%ebp)

	// Unlike standard Unix's putchar,
	// the cputchar function _always_ outputs to the system console.
	sys_cputs(&c, 1);
  8027a0:	c7 44 24 04 01 00 00 	movl   $0x1,0x4(%esp)
  8027a7:	00 
  8027a8:	8d 45 f7             	lea    -0x9(%ebp),%eax
  8027ab:	89 04 24             	mov    %eax,(%esp)
  8027ae:	e8 dd e4 ff ff       	call   800c90 <sys_cputs>
}
  8027b3:	c9                   	leave  
  8027b4:	c3                   	ret    

008027b5 <devcons_read>:
	return fd2num(fd);
}

static ssize_t
devcons_read(struct Fd *fd, void *vbuf, size_t n)
{
  8027b5:	55                   	push   %ebp
  8027b6:	89 e5                	mov    %esp,%ebp
  8027b8:	83 ec 08             	sub    $0x8,%esp
	int c;

	if (n == 0)
  8027bb:	83 7d 10 00          	cmpl   $0x0,0x10(%ebp)
  8027bf:	75 07                	jne    8027c8 <devcons_read+0x13>
  8027c1:	eb 2d                	jmp    8027f0 <devcons_read+0x3b>
		return 0;
	while ((c = sys_cgetc()) == 0)
		sys_yield();
  8027c3:	e8 8d e8 ff ff       	call   801055 <sys_yield>
{
	int c;

	if (n == 0)
		return 0;
	while ((c = sys_cgetc()) == 0)
  8027c8:	90                   	nop
  8027c9:	8d b4 26 00 00 00 00 	lea    0x0(%esi,%eiz,1),%esi
  8027d0:	e8 87 e4 ff ff       	call   800c5c <sys_cgetc>
  8027d5:	85 c0                	test   %eax,%eax
  8027d7:	74 ea                	je     8027c3 <devcons_read+0xe>
  8027d9:	89 c2                	mov    %eax,%edx
		sys_yield();
	if (c < 0)
  8027db:	85 c0                	test   %eax,%eax
  8027dd:	78 16                	js     8027f5 <devcons_read+0x40>
		return c;
	if (c == 0x04)	// ctl-d is eof
  8027df:	83 f8 04             	cmp    $0x4,%eax
  8027e2:	74 0c                	je     8027f0 <devcons_read+0x3b>
		return 0;
	*(char*)vbuf = c;
  8027e4:	8b 45 0c             	mov    0xc(%ebp),%eax
  8027e7:	88 10                	mov    %dl,(%eax)
  8027e9:	b8 01 00 00 00       	mov    $0x1,%eax
	return 1;
  8027ee:	eb 05                	jmp    8027f5 <devcons_read+0x40>
  8027f0:	b8 00 00 00 00       	mov    $0x0,%eax
}
  8027f5:	c9                   	leave  
  8027f6:	c3                   	ret    

008027f7 <opencons>:
	return fd->fd_dev_id == devcons.dev_id;
}

int
opencons(void)
{
  8027f7:	55                   	push   %ebp
  8027f8:	89 e5                	mov    %esp,%ebp
  8027fa:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd* fd;

	if ((r = fd_alloc(&fd)) < 0)
  8027fd:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802800:	89 04 24             	mov    %eax,(%esp)
  802803:	e8 43 ed ff ff       	call   80154b <fd_alloc>
  802808:	85 c0                	test   %eax,%eax
  80280a:	78 3f                	js     80284b <opencons+0x54>
		return r;
	if ((r = sys_page_alloc(0, fd, PTE_P|PTE_U|PTE_W|PTE_SHARE)) < 0)
  80280c:	c7 44 24 08 07 04 00 	movl   $0x407,0x8(%esp)
  802813:	00 
  802814:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802817:	89 44 24 04          	mov    %eax,0x4(%esp)
  80281b:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802822:	e8 cf e7 ff ff       	call   800ff6 <sys_page_alloc>
  802827:	85 c0                	test   %eax,%eax
  802829:	78 20                	js     80284b <opencons+0x54>
		return r;
	fd->fd_dev_id = devcons.dev_id;
  80282b:	8b 15 58 70 80 00    	mov    0x807058,%edx
  802831:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802834:	89 10                	mov    %edx,(%eax)
	fd->fd_omode = O_RDWR;
  802836:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802839:	c7 40 08 02 00 00 00 	movl   $0x2,0x8(%eax)
	return fd2num(fd);
  802840:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802843:	89 04 24             	mov    %eax,(%esp)
  802846:	e8 d5 ec ff ff       	call   801520 <fd2num>
}
  80284b:	c9                   	leave  
  80284c:	c3                   	ret    

0080284d <iscons>:
	.dev_stat =	devcons_stat
};

int
iscons(int fdnum)
{
  80284d:	55                   	push   %ebp
  80284e:	89 e5                	mov    %esp,%ebp
  802850:	83 ec 28             	sub    $0x28,%esp
	int r;
	struct Fd *fd;

	if ((r = fd_lookup(fdnum, &fd)) < 0)
  802853:	8d 45 f4             	lea    -0xc(%ebp),%eax
  802856:	89 44 24 04          	mov    %eax,0x4(%esp)
  80285a:	8b 45 08             	mov    0x8(%ebp),%eax
  80285d:	89 04 24             	mov    %eax,(%esp)
  802860:	e8 58 ed ff ff       	call   8015bd <fd_lookup>
  802865:	85 c0                	test   %eax,%eax
  802867:	78 11                	js     80287a <iscons+0x2d>
		return r;
	return fd->fd_dev_id == devcons.dev_id;
  802869:	8b 45 f4             	mov    -0xc(%ebp),%eax
  80286c:	8b 00                	mov    (%eax),%eax
  80286e:	3b 05 58 70 80 00    	cmp    0x807058,%eax
  802874:	0f 94 c0             	sete   %al
  802877:	0f b6 c0             	movzbl %al,%eax
}
  80287a:	c9                   	leave  
  80287b:	c3                   	ret    

0080287c <getchar>:
	sys_cputs(&c, 1);
}

int
getchar(void)
{
  80287c:	55                   	push   %ebp
  80287d:	89 e5                	mov    %esp,%ebp
  80287f:	83 ec 28             	sub    $0x28,%esp
	int r;

	// JOS does, however, support standard _input_ redirection,
	// allowing the user to redirect script files to the shell and such.
	// getchar() reads a character from file descriptor 0.
	r = read(0, &c, 1);
  802882:	c7 44 24 08 01 00 00 	movl   $0x1,0x8(%esp)
  802889:	00 
  80288a:	8d 45 f7             	lea    -0x9(%ebp),%eax
  80288d:	89 44 24 04          	mov    %eax,0x4(%esp)
  802891:	c7 04 24 00 00 00 00 	movl   $0x0,(%esp)
  802898:	e8 86 ef ff ff       	call   801823 <read>
	if (r < 0)
  80289d:	85 c0                	test   %eax,%eax
  80289f:	78 0f                	js     8028b0 <getchar+0x34>
		return r;
	if (r < 1)
  8028a1:	85 c0                	test   %eax,%eax
  8028a3:	7f 07                	jg     8028ac <getchar+0x30>
  8028a5:	b8 f8 ff ff ff       	mov    $0xfffffff8,%eax
  8028aa:	eb 04                	jmp    8028b0 <getchar+0x34>
		return -E_EOF;
	return c;
  8028ac:	0f b6 45 f7          	movzbl -0x9(%ebp),%eax
}
  8028b0:	c9                   	leave  
  8028b1:	c3                   	ret    
	...

008028b4 <_panic>:
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
{
  8028b4:	55                   	push   %ebp
  8028b5:	89 e5                	mov    %esp,%ebp
  8028b7:	53                   	push   %ebx
  8028b8:	83 ec 14             	sub    $0x14,%esp
 * Panic is called on unresolvable fatal errors.
 * It prints "panic: <message>", then causes a breakpoint exception,
 * which causes JOS to enter the JOS kernel monitor.
 */
void
_panic(const char *file, int line, const char *fmt,...)
  8028bb:	8d 5d 14             	lea    0x14(%ebp),%ebx
	va_list ap;

	va_start(ap, fmt);

	// Print the panic message
	if (argv0)
  8028be:	a1 7c 70 80 00       	mov    0x80707c,%eax
  8028c3:	85 c0                	test   %eax,%eax
  8028c5:	74 10                	je     8028d7 <_panic+0x23>
		cprintf("%s: ", argv0);
  8028c7:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028cb:	c7 04 24 61 33 80 00 	movl   $0x803361,(%esp)
  8028d2:	e8 f2 d8 ff ff       	call   8001c9 <cprintf>
	cprintf("user panic in %s at %s:%d: ", binaryname, file, line);
  8028d7:	8b 45 0c             	mov    0xc(%ebp),%eax
  8028da:	89 44 24 0c          	mov    %eax,0xc(%esp)
  8028de:	8b 45 08             	mov    0x8(%ebp),%eax
  8028e1:	89 44 24 08          	mov    %eax,0x8(%esp)
  8028e5:	a1 00 70 80 00       	mov    0x807000,%eax
  8028ea:	89 44 24 04          	mov    %eax,0x4(%esp)
  8028ee:	c7 04 24 66 33 80 00 	movl   $0x803366,(%esp)
  8028f5:	e8 cf d8 ff ff       	call   8001c9 <cprintf>
	vcprintf(fmt, ap);
  8028fa:	89 5c 24 04          	mov    %ebx,0x4(%esp)
  8028fe:	8b 45 10             	mov    0x10(%ebp),%eax
  802901:	89 04 24             	mov    %eax,(%esp)
  802904:	e8 5f d8 ff ff       	call   800168 <vcprintf>
	cprintf("\n");
  802909:	c7 04 24 54 2d 80 00 	movl   $0x802d54,(%esp)
  802910:	e8 b4 d8 ff ff       	call   8001c9 <cprintf>

	// Cause a breakpoint exception
	while (1)
		asm volatile("int3");
  802915:	cc                   	int3   
  802916:	eb fd                	jmp    802915 <_panic+0x61>

00802918 <set_pgfault_handler>:
// at UXSTACKTOP), and tell the kernel to call the assembly-language
// _pgfault_upcall routine when a page fault occurs.
//
void
set_pgfault_handler(void (*handler)(struct UTrapframe *utf))
{
  802918:	55                   	push   %ebp
  802919:	89 e5                	mov    %esp,%ebp
  80291b:	83 ec 18             	sub    $0x18,%esp
	int r;

	if (_pgfault_handler == NULL) {
  80291e:	83 3d 78 70 80 00 00 	cmpl   $0x0,0x807078
  802925:	75 55                	jne    80297c <set_pgfault_handler+0x64>
		// First time through!
		// LAB 4: Your code here.
        if (sys_page_alloc(sys_getenvid(), (void *)(UXSTACKTOP-PGSIZE), PTE_P|PTE_U|PTE_W))
  802927:	e8 5d e7 ff ff       	call   801089 <sys_getenvid>
  80292c:	c7 44 24 08 07 00 00 	movl   $0x7,0x8(%esp)
  802933:	00 
  802934:	c7 44 24 04 00 f0 bf 	movl   $0xeebff000,0x4(%esp)
  80293b:	ee 
  80293c:	89 04 24             	mov    %eax,(%esp)
  80293f:	e8 b2 e6 ff ff       	call   800ff6 <sys_page_alloc>
  802944:	85 c0                	test   %eax,%eax
  802946:	74 1c                	je     802964 <set_pgfault_handler+0x4c>
		    panic("set_pgfault_handler not implemented");
  802948:	c7 44 24 08 84 33 80 	movl   $0x803384,0x8(%esp)
  80294f:	00 
  802950:	c7 44 24 04 21 00 00 	movl   $0x21,0x4(%esp)
  802957:	00 
  802958:	c7 04 24 a8 33 80 00 	movl   $0x8033a8,(%esp)
  80295f:	e8 50 ff ff ff       	call   8028b4 <_panic>
        sys_env_set_pgfault_upcall(env->env_id, _pgfault_upcall);
  802964:	a1 74 70 80 00       	mov    0x807074,%eax
  802969:	8b 40 4c             	mov    0x4c(%eax),%eax
  80296c:	c7 44 24 04 88 29 80 	movl   $0x802988,0x4(%esp)
  802973:	00 
  802974:	89 04 24             	mov    %eax,(%esp)
  802977:	e8 a4 e4 ff ff       	call   800e20 <sys_env_set_pgfault_upcall>
	}

	// Save handler pointer for assembly to call.
	_pgfault_handler = handler;
  80297c:	8b 45 08             	mov    0x8(%ebp),%eax
  80297f:	a3 78 70 80 00       	mov    %eax,0x807078
}
  802984:	c9                   	leave  
  802985:	c3                   	ret    
	...

00802988 <_pgfault_upcall>:

.text
.globl _pgfault_upcall
_pgfault_upcall:
	// Call the C page fault handler.
	pushl %esp			// function argument: pointer to UTF
  802988:	54                   	push   %esp
	movl _pgfault_handler, %eax
  802989:	a1 78 70 80 00       	mov    0x807078,%eax
	call *%eax
  80298e:	ff d0                	call   *%eax
	addl $4, %esp			// pop function argument
  802990:	83 c4 04             	add    $0x4,%esp
	// may find that you have to rearrange your code in non-obvious
	// ways as registers become unavailable as scratch space.
	//
	// LAB 4: Your code here.

    subl $4, 48(%esp)
  802993:	83 6c 24 30 04       	subl   $0x4,0x30(%esp)
    movl 48(%esp), %eax
  802998:	8b 44 24 30          	mov    0x30(%esp),%eax
    movl 40(%esp), %ebx
  80299c:	8b 5c 24 28          	mov    0x28(%esp),%ebx
    movl %ebx, (%eax)
  8029a0:	89 18                	mov    %ebx,(%eax)
    
	// Restore the trap-time registers.  After you do this, you
	// can no longer modify any general-purpose registers.
	// LAB 4: Your code here.
    addl $8, %esp
  8029a2:	83 c4 08             	add    $0x8,%esp
    popal
  8029a5:	61                   	popa   
   
	// Restore eflags from the stack.  After you do this, you can
	// no longer use arithmetic operations or anything else that
	// modifies eflags.
	// LAB 4: Your code here.
    pushl 4(%esp)
  8029a6:	ff 74 24 04          	pushl  0x4(%esp)
    popf
  8029aa:	9d                   	popf   

	// Switch back to the adjusted trap-time stack.
	// LAB 4: Your code here.
    movl 8(%esp), %esp
  8029ab:	8b 64 24 08          	mov    0x8(%esp),%esp

	// Return to re-execute the instruction that faulted.
	// LAB 4: Your code here.
    ret
  8029af:	c3                   	ret    

008029b0 <ipc_send>:
//   Use sys_yield() to be CPU-friendly.
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value.)
void
ipc_send(envid_t to_env, uint32_t val, void *pg, int perm)
{
  8029b0:	55                   	push   %ebp
  8029b1:	89 e5                	mov    %esp,%ebp
  8029b3:	57                   	push   %edi
  8029b4:	56                   	push   %esi
  8029b5:	53                   	push   %ebx
  8029b6:	83 ec 2c             	sub    $0x2c,%esp
  8029b9:	8b 75 08             	mov    0x8(%ebp),%esi
  8029bc:	8b 7d 0c             	mov    0xc(%ebp),%edi
  8029bf:	8b 5d 10             	mov    0x10(%ebp),%ebx
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
  8029c2:	85 db                	test   %ebx,%ebx
  8029c4:	b8 00 00 c0 ee       	mov    $0xeec00000,%eax
  8029c9:	0f 45 c3             	cmovne %ebx,%eax
  8029cc:	8b 55 14             	mov    0x14(%ebp),%edx
  8029cf:	89 54 24 0c          	mov    %edx,0xc(%esp)
  8029d3:	89 44 24 08          	mov    %eax,0x8(%esp)
  8029d7:	89 7c 24 04          	mov    %edi,0x4(%esp)
  8029db:	89 34 24             	mov    %esi,(%esp)
  8029de:	e8 dd e3 ff ff       	call   800dc0 <sys_ipc_try_send>
  8029e3:	83 f8 f9             	cmp    $0xfffffff9,%eax
  8029e6:	75 0a                	jne    8029f2 <ipc_send+0x42>
      sys_yield();
  8029e8:	e8 68 e6 ff ff       	call   801055 <sys_yield>
    else if (r < 0)
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
    else
      return;
  }
  8029ed:	8d 76 00             	lea    0x0(%esi),%esi
  8029f0:	eb d0                	jmp    8029c2 <ipc_send+0x12>
{
  int r   = 0;
  while (1) {
    if ((r=sys_ipc_try_send(to_env, val, (pg==NULL?(void *)UTOP:pg), perm)) == -E_IPC_NOT_RECV)
      sys_yield();
    else if (r < 0)
  8029f2:	85 c0                	test   %eax,%eax
  8029f4:	79 24                	jns    802a1a <ipc_send+0x6a>
      panic("ipc_send to [%x] failed. Error: %x\n", to_env, r);
  8029f6:	89 44 24 10          	mov    %eax,0x10(%esp)
  8029fa:	89 74 24 0c          	mov    %esi,0xc(%esp)
  8029fe:	c7 44 24 08 b8 33 80 	movl   $0x8033b8,0x8(%esp)
  802a05:	00 
  802a06:	c7 44 24 04 36 00 00 	movl   $0x36,0x4(%esp)
  802a0d:	00 
  802a0e:	c7 04 24 dc 33 80 00 	movl   $0x8033dc,(%esp)
  802a15:	e8 9a fe ff ff       	call   8028b4 <_panic>
    else
      return;
  }
}
  802a1a:	83 c4 2c             	add    $0x2c,%esp
  802a1d:	5b                   	pop    %ebx
  802a1e:	5e                   	pop    %esi
  802a1f:	5f                   	pop    %edi
  802a20:	5d                   	pop    %ebp
  802a21:	c3                   	ret    

00802a22 <ipc_recv>:
//   If 'pg' is null, pass sys_ipc_recv a value that it will understand
//   as meaning "no page".  (Zero is not the right value, since that's
//   a perfectly valid place to map a page.)
int32_t
ipc_recv(envid_t *from_env_store, void *pg, int *perm_store)
{
  802a22:	55                   	push   %ebp
  802a23:	89 e5                	mov    %esp,%ebp
  802a25:	56                   	push   %esi
  802a26:	53                   	push   %ebx
  802a27:	83 ec 10             	sub    $0x10,%esp
  802a2a:	8b 5d 08             	mov    0x8(%ebp),%ebx
  802a2d:	8b 45 0c             	mov    0xc(%ebp),%eax
  802a30:	8b 75 10             	mov    0x10(%ebp),%esi
  int r;
  if ((r=sys_ipc_recv((pg==NULL?(void *)UTOP:pg)))<0)
  802a33:	85 c0                	test   %eax,%eax
  802a35:	ba 00 00 c0 ee       	mov    $0xeec00000,%edx
  802a3a:	0f 44 c2             	cmove  %edx,%eax
  802a3d:	89 04 24             	mov    %eax,(%esp)
  802a40:	e8 1e e3 ff ff       	call   800d63 <sys_ipc_recv>
  802a45:	85 c0                	test   %eax,%eax
  802a47:	78 24                	js     802a6d <ipc_recv+0x4b>
    return r;

  if (from_env_store)
  802a49:	85 db                	test   %ebx,%ebx
  802a4b:	74 0a                	je     802a57 <ipc_recv+0x35>
    *from_env_store = env->env_ipc_from;
  802a4d:	a1 74 70 80 00       	mov    0x807074,%eax
  802a52:	8b 40 74             	mov    0x74(%eax),%eax
  802a55:	89 03                	mov    %eax,(%ebx)

  if (perm_store)
  802a57:	85 f6                	test   %esi,%esi
  802a59:	74 0a                	je     802a65 <ipc_recv+0x43>
    *perm_store     = env->env_ipc_perm;
  802a5b:	a1 74 70 80 00       	mov    0x807074,%eax
  802a60:	8b 40 78             	mov    0x78(%eax),%eax
  802a63:	89 06                	mov    %eax,(%esi)

  return env->env_ipc_value;
  802a65:	a1 74 70 80 00       	mov    0x807074,%eax
  802a6a:	8b 40 70             	mov    0x70(%eax),%eax
}
  802a6d:	83 c4 10             	add    $0x10,%esp
  802a70:	5b                   	pop    %ebx
  802a71:	5e                   	pop    %esi
  802a72:	5d                   	pop    %ebp
  802a73:	c3                   	ret    

00802a74 <pageref>:
#include <inc/lib.h>

int
pageref(void *v)
{
  802a74:	55                   	push   %ebp
  802a75:	89 e5                	mov    %esp,%ebp
	pte_t pte;

	if (!(vpd[PDX(v)] & PTE_P))
  802a77:	8b 45 08             	mov    0x8(%ebp),%eax
  802a7a:	89 c2                	mov    %eax,%edx
  802a7c:	c1 ea 16             	shr    $0x16,%edx
  802a7f:	8b 14 95 00 d0 7b ef 	mov    -0x10843000(,%edx,4),%edx
  802a86:	f6 c2 01             	test   $0x1,%dl
  802a89:	74 26                	je     802ab1 <pageref+0x3d>
		return 0;
	pte = vpt[VPN(v)];
  802a8b:	c1 e8 0c             	shr    $0xc,%eax
  802a8e:	8b 04 85 00 00 40 ef 	mov    -0x10c00000(,%eax,4),%eax
	if (!(pte & PTE_P))
  802a95:	a8 01                	test   $0x1,%al
  802a97:	74 18                	je     802ab1 <pageref+0x3d>
		return 0;
	return pages[PPN(pte)].pp_ref;
  802a99:	c1 e8 0c             	shr    $0xc,%eax
  802a9c:	8d 14 40             	lea    (%eax,%eax,2),%edx
  802a9f:	c1 e2 02             	shl    $0x2,%edx
  802aa2:	b8 00 00 00 ef       	mov    $0xef000000,%eax
  802aa7:	0f b7 44 02 08       	movzwl 0x8(%edx,%eax,1),%eax
  802aac:	0f b7 c0             	movzwl %ax,%eax
  802aaf:	eb 05                	jmp    802ab6 <pageref+0x42>
  802ab1:	b8 00 00 00 00       	mov    $0x0,%eax
}
  802ab6:	5d                   	pop    %ebp
  802ab7:	c3                   	ret    
	...

00802ac0 <__udivdi3>:
  802ac0:	55                   	push   %ebp
  802ac1:	89 e5                	mov    %esp,%ebp
  802ac3:	57                   	push   %edi
  802ac4:	56                   	push   %esi
  802ac5:	83 ec 10             	sub    $0x10,%esp
  802ac8:	8b 45 14             	mov    0x14(%ebp),%eax
  802acb:	8b 55 08             	mov    0x8(%ebp),%edx
  802ace:	8b 75 10             	mov    0x10(%ebp),%esi
  802ad1:	8b 7d 0c             	mov    0xc(%ebp),%edi
  802ad4:	85 c0                	test   %eax,%eax
  802ad6:	89 55 f0             	mov    %edx,-0x10(%ebp)
  802ad9:	75 35                	jne    802b10 <__udivdi3+0x50>
  802adb:	39 fe                	cmp    %edi,%esi
  802add:	77 61                	ja     802b40 <__udivdi3+0x80>
  802adf:	85 f6                	test   %esi,%esi
  802ae1:	75 0b                	jne    802aee <__udivdi3+0x2e>
  802ae3:	b8 01 00 00 00       	mov    $0x1,%eax
  802ae8:	31 d2                	xor    %edx,%edx
  802aea:	f7 f6                	div    %esi
  802aec:	89 c6                	mov    %eax,%esi
  802aee:	8b 4d f0             	mov    -0x10(%ebp),%ecx
  802af1:	31 d2                	xor    %edx,%edx
  802af3:	89 f8                	mov    %edi,%eax
  802af5:	f7 f6                	div    %esi
  802af7:	89 c7                	mov    %eax,%edi
  802af9:	89 c8                	mov    %ecx,%eax
  802afb:	f7 f6                	div    %esi
  802afd:	89 c1                	mov    %eax,%ecx
  802aff:	89 fa                	mov    %edi,%edx
  802b01:	89 c8                	mov    %ecx,%eax
  802b03:	83 c4 10             	add    $0x10,%esp
  802b06:	5e                   	pop    %esi
  802b07:	5f                   	pop    %edi
  802b08:	5d                   	pop    %ebp
  802b09:	c3                   	ret    
  802b0a:	8d b6 00 00 00 00    	lea    0x0(%esi),%esi
  802b10:	39 f8                	cmp    %edi,%eax
  802b12:	77 1c                	ja     802b30 <__udivdi3+0x70>
  802b14:	0f bd d0             	bsr    %eax,%edx
  802b17:	83 f2 1f             	xor    $0x1f,%edx
  802b1a:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802b1d:	75 39                	jne    802b58 <__udivdi3+0x98>
  802b1f:	3b 75 f0             	cmp    -0x10(%ebp),%esi
  802b22:	0f 86 a0 00 00 00    	jbe    802bc8 <__udivdi3+0x108>
  802b28:	39 f8                	cmp    %edi,%eax
  802b2a:	0f 82 98 00 00 00    	jb     802bc8 <__udivdi3+0x108>
  802b30:	31 ff                	xor    %edi,%edi
  802b32:	31 c9                	xor    %ecx,%ecx
  802b34:	89 c8                	mov    %ecx,%eax
  802b36:	89 fa                	mov    %edi,%edx
  802b38:	83 c4 10             	add    $0x10,%esp
  802b3b:	5e                   	pop    %esi
  802b3c:	5f                   	pop    %edi
  802b3d:	5d                   	pop    %ebp
  802b3e:	c3                   	ret    
  802b3f:	90                   	nop
  802b40:	89 d1                	mov    %edx,%ecx
  802b42:	89 fa                	mov    %edi,%edx
  802b44:	89 c8                	mov    %ecx,%eax
  802b46:	31 ff                	xor    %edi,%edi
  802b48:	f7 f6                	div    %esi
  802b4a:	89 c1                	mov    %eax,%ecx
  802b4c:	89 fa                	mov    %edi,%edx
  802b4e:	89 c8                	mov    %ecx,%eax
  802b50:	83 c4 10             	add    $0x10,%esp
  802b53:	5e                   	pop    %esi
  802b54:	5f                   	pop    %edi
  802b55:	5d                   	pop    %ebp
  802b56:	c3                   	ret    
  802b57:	90                   	nop
  802b58:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b5c:	89 f2                	mov    %esi,%edx
  802b5e:	d3 e0                	shl    %cl,%eax
  802b60:	89 45 ec             	mov    %eax,-0x14(%ebp)
  802b63:	b8 20 00 00 00       	mov    $0x20,%eax
  802b68:	2b 45 f4             	sub    -0xc(%ebp),%eax
  802b6b:	89 c1                	mov    %eax,%ecx
  802b6d:	d3 ea                	shr    %cl,%edx
  802b6f:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b73:	0b 55 ec             	or     -0x14(%ebp),%edx
  802b76:	d3 e6                	shl    %cl,%esi
  802b78:	89 c1                	mov    %eax,%ecx
  802b7a:	89 75 e8             	mov    %esi,-0x18(%ebp)
  802b7d:	89 fe                	mov    %edi,%esi
  802b7f:	d3 ee                	shr    %cl,%esi
  802b81:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802b85:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802b88:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802b8b:	d3 e7                	shl    %cl,%edi
  802b8d:	89 c1                	mov    %eax,%ecx
  802b8f:	d3 ea                	shr    %cl,%edx
  802b91:	09 d7                	or     %edx,%edi
  802b93:	89 f2                	mov    %esi,%edx
  802b95:	89 f8                	mov    %edi,%eax
  802b97:	f7 75 ec             	divl   -0x14(%ebp)
  802b9a:	89 d6                	mov    %edx,%esi
  802b9c:	89 c7                	mov    %eax,%edi
  802b9e:	f7 65 e8             	mull   -0x18(%ebp)
  802ba1:	39 d6                	cmp    %edx,%esi
  802ba3:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802ba6:	72 30                	jb     802bd8 <__udivdi3+0x118>
  802ba8:	8b 55 f0             	mov    -0x10(%ebp),%edx
  802bab:	0f b6 4d f4          	movzbl -0xc(%ebp),%ecx
  802baf:	d3 e2                	shl    %cl,%edx
  802bb1:	39 c2                	cmp    %eax,%edx
  802bb3:	73 05                	jae    802bba <__udivdi3+0xfa>
  802bb5:	3b 75 ec             	cmp    -0x14(%ebp),%esi
  802bb8:	74 1e                	je     802bd8 <__udivdi3+0x118>
  802bba:	89 f9                	mov    %edi,%ecx
  802bbc:	31 ff                	xor    %edi,%edi
  802bbe:	e9 71 ff ff ff       	jmp    802b34 <__udivdi3+0x74>
  802bc3:	90                   	nop
  802bc4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bc8:	31 ff                	xor    %edi,%edi
  802bca:	b9 01 00 00 00       	mov    $0x1,%ecx
  802bcf:	e9 60 ff ff ff       	jmp    802b34 <__udivdi3+0x74>
  802bd4:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802bd8:	8d 4f ff             	lea    -0x1(%edi),%ecx
  802bdb:	31 ff                	xor    %edi,%edi
  802bdd:	89 c8                	mov    %ecx,%eax
  802bdf:	89 fa                	mov    %edi,%edx
  802be1:	83 c4 10             	add    $0x10,%esp
  802be4:	5e                   	pop    %esi
  802be5:	5f                   	pop    %edi
  802be6:	5d                   	pop    %ebp
  802be7:	c3                   	ret    
	...

00802bf0 <__umoddi3>:
  802bf0:	55                   	push   %ebp
  802bf1:	89 e5                	mov    %esp,%ebp
  802bf3:	57                   	push   %edi
  802bf4:	56                   	push   %esi
  802bf5:	83 ec 20             	sub    $0x20,%esp
  802bf8:	8b 55 14             	mov    0x14(%ebp),%edx
  802bfb:	8b 4d 08             	mov    0x8(%ebp),%ecx
  802bfe:	8b 7d 10             	mov    0x10(%ebp),%edi
  802c01:	8b 75 0c             	mov    0xc(%ebp),%esi
  802c04:	85 d2                	test   %edx,%edx
  802c06:	89 c8                	mov    %ecx,%eax
  802c08:	89 4d f4             	mov    %ecx,-0xc(%ebp)
  802c0b:	75 13                	jne    802c20 <__umoddi3+0x30>
  802c0d:	39 f7                	cmp    %esi,%edi
  802c0f:	76 3f                	jbe    802c50 <__umoddi3+0x60>
  802c11:	89 f2                	mov    %esi,%edx
  802c13:	f7 f7                	div    %edi
  802c15:	89 d0                	mov    %edx,%eax
  802c17:	31 d2                	xor    %edx,%edx
  802c19:	83 c4 20             	add    $0x20,%esp
  802c1c:	5e                   	pop    %esi
  802c1d:	5f                   	pop    %edi
  802c1e:	5d                   	pop    %ebp
  802c1f:	c3                   	ret    
  802c20:	39 f2                	cmp    %esi,%edx
  802c22:	77 4c                	ja     802c70 <__umoddi3+0x80>
  802c24:	0f bd ca             	bsr    %edx,%ecx
  802c27:	83 f1 1f             	xor    $0x1f,%ecx
  802c2a:	89 4d f0             	mov    %ecx,-0x10(%ebp)
  802c2d:	75 51                	jne    802c80 <__umoddi3+0x90>
  802c2f:	3b 7d f4             	cmp    -0xc(%ebp),%edi
  802c32:	0f 87 e0 00 00 00    	ja     802d18 <__umoddi3+0x128>
  802c38:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c3b:	29 f8                	sub    %edi,%eax
  802c3d:	19 d6                	sbb    %edx,%esi
  802c3f:	89 45 f4             	mov    %eax,-0xc(%ebp)
  802c42:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c45:	89 f2                	mov    %esi,%edx
  802c47:	83 c4 20             	add    $0x20,%esp
  802c4a:	5e                   	pop    %esi
  802c4b:	5f                   	pop    %edi
  802c4c:	5d                   	pop    %ebp
  802c4d:	c3                   	ret    
  802c4e:	66 90                	xchg   %ax,%ax
  802c50:	85 ff                	test   %edi,%edi
  802c52:	75 0b                	jne    802c5f <__umoddi3+0x6f>
  802c54:	b8 01 00 00 00       	mov    $0x1,%eax
  802c59:	31 d2                	xor    %edx,%edx
  802c5b:	f7 f7                	div    %edi
  802c5d:	89 c7                	mov    %eax,%edi
  802c5f:	89 f0                	mov    %esi,%eax
  802c61:	31 d2                	xor    %edx,%edx
  802c63:	f7 f7                	div    %edi
  802c65:	8b 45 f4             	mov    -0xc(%ebp),%eax
  802c68:	f7 f7                	div    %edi
  802c6a:	eb a9                	jmp    802c15 <__umoddi3+0x25>
  802c6c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c70:	89 c8                	mov    %ecx,%eax
  802c72:	89 f2                	mov    %esi,%edx
  802c74:	83 c4 20             	add    $0x20,%esp
  802c77:	5e                   	pop    %esi
  802c78:	5f                   	pop    %edi
  802c79:	5d                   	pop    %ebp
  802c7a:	c3                   	ret    
  802c7b:	90                   	nop
  802c7c:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802c80:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802c84:	d3 e2                	shl    %cl,%edx
  802c86:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802c89:	ba 20 00 00 00       	mov    $0x20,%edx
  802c8e:	2b 55 f0             	sub    -0x10(%ebp),%edx
  802c91:	89 55 ec             	mov    %edx,-0x14(%ebp)
  802c94:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802c98:	89 fa                	mov    %edi,%edx
  802c9a:	d3 ea                	shr    %cl,%edx
  802c9c:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ca0:	0b 55 f4             	or     -0xc(%ebp),%edx
  802ca3:	d3 e7                	shl    %cl,%edi
  802ca5:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802ca9:	89 55 f4             	mov    %edx,-0xc(%ebp)
  802cac:	89 f2                	mov    %esi,%edx
  802cae:	89 7d e8             	mov    %edi,-0x18(%ebp)
  802cb1:	89 c7                	mov    %eax,%edi
  802cb3:	d3 ea                	shr    %cl,%edx
  802cb5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cb9:	89 55 e4             	mov    %edx,-0x1c(%ebp)
  802cbc:	89 c2                	mov    %eax,%edx
  802cbe:	d3 e6                	shl    %cl,%esi
  802cc0:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802cc4:	d3 ea                	shr    %cl,%edx
  802cc6:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cca:	09 d6                	or     %edx,%esi
  802ccc:	89 f0                	mov    %esi,%eax
  802cce:	8b 75 e4             	mov    -0x1c(%ebp),%esi
  802cd1:	d3 e7                	shl    %cl,%edi
  802cd3:	89 f2                	mov    %esi,%edx
  802cd5:	f7 75 f4             	divl   -0xc(%ebp)
  802cd8:	89 d6                	mov    %edx,%esi
  802cda:	f7 65 e8             	mull   -0x18(%ebp)
  802cdd:	39 d6                	cmp    %edx,%esi
  802cdf:	72 2b                	jb     802d0c <__umoddi3+0x11c>
  802ce1:	39 c7                	cmp    %eax,%edi
  802ce3:	72 23                	jb     802d08 <__umoddi3+0x118>
  802ce5:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802ce9:	29 c7                	sub    %eax,%edi
  802ceb:	19 d6                	sbb    %edx,%esi
  802ced:	89 f0                	mov    %esi,%eax
  802cef:	89 f2                	mov    %esi,%edx
  802cf1:	d3 ef                	shr    %cl,%edi
  802cf3:	0f b6 4d ec          	movzbl -0x14(%ebp),%ecx
  802cf7:	d3 e0                	shl    %cl,%eax
  802cf9:	0f b6 4d f0          	movzbl -0x10(%ebp),%ecx
  802cfd:	09 f8                	or     %edi,%eax
  802cff:	d3 ea                	shr    %cl,%edx
  802d01:	83 c4 20             	add    $0x20,%esp
  802d04:	5e                   	pop    %esi
  802d05:	5f                   	pop    %edi
  802d06:	5d                   	pop    %ebp
  802d07:	c3                   	ret    
  802d08:	39 d6                	cmp    %edx,%esi
  802d0a:	75 d9                	jne    802ce5 <__umoddi3+0xf5>
  802d0c:	2b 45 e8             	sub    -0x18(%ebp),%eax
  802d0f:	1b 55 f4             	sbb    -0xc(%ebp),%edx
  802d12:	eb d1                	jmp    802ce5 <__umoddi3+0xf5>
  802d14:	8d 74 26 00          	lea    0x0(%esi,%eiz,1),%esi
  802d18:	39 f2                	cmp    %esi,%edx
  802d1a:	0f 82 18 ff ff ff    	jb     802c38 <__umoddi3+0x48>
  802d20:	e9 1d ff ff ff       	jmp    802c42 <__umoddi3+0x52>
